github.com/klaytn/klaytn@v1.12.1/node/cn/tracers/make_testdata.js (about) 1 var makeTest = function(tx, rewind) { 2 // Generate the genesis block from the block, transaction and prestate data 3 var block = klay.getBlock(klay.getTransaction(tx).blockHash); 4 var genesis = klay.getBlock(block.parentHash); 5 6 delete genesis.gasUsed; 7 delete genesis.logsBloom; 8 delete genesis.parentHash; 9 delete genesis.receiptsRoot; 10 delete genesis.size; 11 delete genesis.transactions; 12 delete genesis.transactionsRoot; 13 delete genesis.governanceData; 14 delete genesis.voteData; 15 16 // genesis.gasLimit = genesis.gasLimit.toString(); 17 genesis.number = genesis.number.toString(); 18 genesis.timestamp = genesis.timestamp.toString(); 19 20 genesis.alloc = debug.traceTransaction(tx, {tracer: "prestateTracer", rewind: rewind}); 21 for (var key in genesis.alloc) { 22 genesis.alloc[key].nonce = genesis.alloc[key].nonce.toString(); 23 } 24 genesis.config = admin.nodeInfo.protocols.istanbul.config; 25 26 // Generate the call trace and produce the test input 27 var result = ""; 28 var result = debug.traceTransaction(tx, {tracer: "callTracer", rewind: rewind}); 29 delete result.time; 30 31 console.log(JSON.stringify({ 32 genesis: genesis, 33 context: { 34 number: block.number.toString(), 35 blockscore: block.blockscore, 36 timestamp: block.timestamp.toString(), 37 }, 38 input: klay.getRawTransaction(tx), 39 result: result, 40 }, null, 2)); 41 }