UPGRADE web3 to 1.0.0-beta.55

pull/49/head
pubkey 6 years ago
parent b5c34fbd61
commit 155caaeab0
  1. 2
      package.json
  2. 46
      test/integration.test.js
  3. 5
      test/tutorials/signed-data.test.js
  4. 3
      tutorials/signed-data.md

@ -103,7 +103,7 @@
"ts-node": "8.1.0",
"typescript": "3.4.5",
"uglify-es": "3.3.9",
"web3": "1.0.0-beta.34",
"web3": "1.0.0-beta.55",
"webpack": "4.29.6",
"webpack-bundle-analyzer": "3.3.2",
"webpack-cli": "3.3.2"

@ -8,19 +8,31 @@ const EthCrypto = require('../dist/lib/index');
// const web3 = EthCrypto.util.web3;
describe('integration.test.js', () => {
/**
* we have to set ''http://'' because:
* @link https://github.com/ethereum/web3.js/issues/2786#issuecomment-490161182
*/
const WEB3_DEFAULT_PROVIDER = 'http://';
const WEB3_CONFIRMATION_BLOCKS = 1;
const state = {
web3: null,
accounts: []
};
describe('init', () => {
it('compiled contract', async function() {
it('compiled contract', async function () {
this.timeout(30 * 1000);
const contractPath = path.join(__dirname, '../contracts/TestContract.sol');
const compiled = await SolidityCli.compileFile(contractPath);
state.compiled = compiled[':TestContract'];
});
it('create web3', () => {
state.web3 = new Web3();
/**
* we have to set ''http://'' because:
* @link https://github.com/ethereum/web3.js/issues/2786#issuecomment-490161182
*/
state.web3 = new Web3(WEB3_DEFAULT_PROVIDER);
state.web3.transactionConfirmationBlocks = WEB3_CONFIRMATION_BLOCKS;
});
it('create testnet', async () => {
// create accounts
@ -69,7 +81,8 @@ describe('integration.test.js', () => {
});
describe('privateKey', () => {
it('should be possible to use the keys with ganache', async () => {
const web3 = new Web3();
const web3 = new Web3(WEB3_DEFAULT_PROVIDER);
web3.transactionConfirmationBlocks = WEB3_CONFIRMATION_BLOCKS;
const ganacheAccounts = new Array(10)
.fill(0)
.map(() => EthCrypto.createIdentity())
@ -84,7 +97,8 @@ describe('integration.test.js', () => {
it('should be possible to sign transaction with the key', async () => {
const identity = EthCrypto.createIdentity();
const web3 = new Web3();
const web3 = new Web3(WEB3_DEFAULT_PROVIDER);
web3.transactionConfirmationBlocks = WEB3_CONFIRMATION_BLOCKS;
web3.setProvider(ganache.provider({
accounts: [{
secretKey: new Buffer(identity.privateKey.replace(/^.{2}/g, ''), 'hex'),
@ -285,18 +299,18 @@ describe('integration.test.js', () => {
// send 3 transactions
await Promise.all(
new Array(3)
.fill(0)
.map(async () => {
const rawTx = {
from: account.address,
to: account2.address,
gasPrice: parseInt(gasPrice),
value: 1
};
const estimateGas = await state.web3.eth.estimateGas(rawTx);
rawTx.gasLimit = estimateGas * 2;
await state.web3.eth.sendTransaction(rawTx);
})
.fill(0)
.map(async () => {
const rawTx = {
from: account.address,
to: account2.address,
gasPrice: parseInt(gasPrice),
value: 1
};
const estimateGas = await state.web3.eth.estimateGas(rawTx);
rawTx.gasLimit = estimateGas * 2;
await state.web3.eth.sendTransaction(rawTx);
})
);
const calculatedAddress = EthCrypto.calculateContractAddress(

@ -13,7 +13,10 @@ describe('signed-data.md', () => {
this.timeout(12000);
const creatorIdentity = EthCrypto.createIdentity();
const recieverIdentity = EthCrypto.createIdentity();
const web3 = new Web3();
const web3 = new Web3('http://');
web3.transactionConfirmationBlocks = 1;
const ganacheProvider = ganache.provider({
accounts: [
// we preset the balance of our identity to 10 ether

@ -20,7 +20,8 @@ const Web3 = require('web3');
const ganache = require('ganache-cli');
// create a web3-instance
const web3 = new Web3();
const web3 = new Web3('http://'); // set 'http://' because web3 needs a provider
web3.transactionConfirmationBlocks = 1; // set confirmations-blocks to 1 for fast testing
// create a ganache-provider
const ganacheProvider = ganache.provider({

Loading…
Cancel
Save