Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Update trie.js, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjpaterno committed Feb 23, 2019
1 parent dee3f7d commit 07b17fb
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions test/trie.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
var Ganache = require(process.env.TEST_BUILD
const Ganache = require(process.env.TEST_BUILD
? "../build/ganache.core." + process.env.TEST_BUILD + ".js"
: "../index.js");
const genSend = require("./helpers/utils/rpc");

describe.only("trie", function() {
it("should work", async() => {
const blockNumber = 7255067;

const Web3 = require("web3");
var web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/metamask"));
const web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/metamask"));
const blockjson = await web3.eth.getBlock(blockNumber, true);

const unlockedAccounts = blockjson.transactions.map((tx) => {
Expand All @@ -22,38 +23,19 @@ describe.only("trie", function() {
fork_block_number: blockNumber - 1,
unlocked_accounts: unlockedAccounts
});
const send = require("util").promisify(provider.send.bind(provider));
const send = genSend(provider);

await send({
id: `${new Date().getTime()}`,
jsonrpc: "2.0",
method: "miner_stop"
});
await send("miner_stop");

const pendingResults = blockjson.transactions.map(async(tx) => {
const value = send({
id: `${new Date().getTime()}`,
jsonrpc: "2.0",
method: "eth_sendTransaction",
params: [tx]
});
return value;
return send("eth_sendTransaction", tx);
});
const results = await Promise.all(pendingResults);
console.log(results);

await send({
id: `${new Date().getTime()}`,
jsonrpc: "2.0",
method: "evm_mine"
});
await send("evm_mine");

const block = await send({
id: `${new Date().getTime()}`,
jsonrpc: "2.0",
method: "eth_getBlockByNumber",
params: ["0x" + blockNumber.toString(16), true]
});
const block = await send("eth_getBlockByNumber", `0x${blockNumber.toString(16)}`, true);

console.log(
block.result.transactionsRoot === blockjson.transactionsRoot,
Expand Down

0 comments on commit 07b17fb

Please sign in to comment.