File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,12 +5,40 @@ module.exports = class TestBlockMiddleware {
55
66 constructor ( ) {
77 this . _blockchain = { }
8+ this . _pendingTxs = [ ]
89 this . setCurrentBlock ( createBlock ( { number : '0x01' } ) )
910 }
1011
1112 nextBlock ( ) {
13+ // prepare next block
1214 const nextNumber = incrementHexNumber ( this . currentBlock . number )
13- this . setCurrentBlock ( createBlock ( { number : nextNumber } ) )
15+ const nextBlock = createBlock ( { number : nextNumber } )
16+ // import pending txs into block
17+ nextBlock . transactions = this . _pendingTxs
18+ this . _pendingTxs = [ ]
19+ // set as current block
20+ this . setCurrentBlock ( nextBlock )
21+ }
22+
23+ addTx ( txParams ) {
24+ const newTx = Object . assign ( {
25+ // defaults
26+ address : randomHash ( ) ,
27+ topics : [
28+ randomHash ( ) ,
29+ randomHash ( ) ,
30+ randomHash ( )
31+ ] ,
32+ data : randomHash ( ) ,
33+ blockNumber : '0xdeadbeef' ,
34+ logIndex : '0xdeadbeef' ,
35+ blockHash : '0x7c337eac9e3ec7bc99a1d911d326389558c9086afca7480a19698a16e40b2e0a' ,
36+ transactionHash : '0xd81da851bd3f4094d52cb86929e2ea3732a60ba7c184b853795fc5710a68b5fa' ,
37+ transactionIndex : '0x0'
38+ // provided
39+ } , txParams )
40+ this . _pendingTxs . push ( newTx )
41+ return newTx
1442 }
1543
1644 setCurrentBlock ( blockParams ) {
You can’t perform that action at this time.
0 commit comments