|
|
@ -17,7 +17,6 @@ |
|
|
|
package eth |
|
|
|
package eth |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
"math/rand" |
|
|
|
"math/rand" |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
@ -448,12 +447,12 @@ func testGetNodeData(t *testing.T, protocol int) { |
|
|
|
switch i { |
|
|
|
switch i { |
|
|
|
case 0: |
|
|
|
case 0: |
|
|
|
// In block 1, the test bank sends account #1 some ether.
|
|
|
|
// In block 1, the test bank sends account #1 some ether.
|
|
|
|
tx, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey) |
|
|
|
tx, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey) |
|
|
|
block.AddTx(tx) |
|
|
|
block.AddTx(tx) |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
// In block 2, the test bank sends some more ether to account #1.
|
|
|
|
// In block 2, the test bank sends some more ether to account #1.
|
|
|
|
// acc1Addr passes it on to account #2.
|
|
|
|
// acc1Addr passes it on to account #2.
|
|
|
|
tx1, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey) |
|
|
|
tx1, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey) |
|
|
|
tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(acc1Key) |
|
|
|
tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(acc1Key) |
|
|
|
block.AddTx(tx1) |
|
|
|
block.AddTx(tx1) |
|
|
|
block.AddTx(tx2) |
|
|
|
block.AddTx(tx2) |
|
|
@ -498,14 +497,14 @@ func testGetNodeData(t *testing.T, protocol int) { |
|
|
|
// Verify that all hashes correspond to the requested data, and reconstruct a state tree
|
|
|
|
// Verify that all hashes correspond to the requested data, and reconstruct a state tree
|
|
|
|
for i, want := range hashes { |
|
|
|
for i, want := range hashes { |
|
|
|
if hash := crypto.Keccak256Hash(data[i]); hash != want { |
|
|
|
if hash := crypto.Keccak256Hash(data[i]); hash != want { |
|
|
|
fmt.Errorf("data hash mismatch: have %x, want %x", hash, want) |
|
|
|
t.Errorf("data hash mismatch: have %x, want %x", hash, want) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
statedb, _ := ethdb.NewMemDatabase() |
|
|
|
statedb, _ := ethdb.NewMemDatabase() |
|
|
|
for i := 0; i < len(data); i++ { |
|
|
|
for i := 0; i < len(data); i++ { |
|
|
|
statedb.Put(hashes[i].Bytes(), data[i]) |
|
|
|
statedb.Put(hashes[i].Bytes(), data[i]) |
|
|
|
} |
|
|
|
} |
|
|
|
accounts := []common.Address{testBankAddress, acc1Addr, acc2Addr} |
|
|
|
accounts := []common.Address{testBank.Address, acc1Addr, acc2Addr} |
|
|
|
for i := uint64(0); i <= pm.blockchain.CurrentBlock().NumberU64(); i++ { |
|
|
|
for i := uint64(0); i <= pm.blockchain.CurrentBlock().NumberU64(); i++ { |
|
|
|
trie, _ := state.New(pm.blockchain.GetBlockByNumber(i).Root(), statedb) |
|
|
|
trie, _ := state.New(pm.blockchain.GetBlockByNumber(i).Root(), statedb) |
|
|
|
|
|
|
|
|
|
|
@ -539,12 +538,12 @@ func testGetReceipt(t *testing.T, protocol int) { |
|
|
|
switch i { |
|
|
|
switch i { |
|
|
|
case 0: |
|
|
|
case 0: |
|
|
|
// In block 1, the test bank sends account #1 some ether.
|
|
|
|
// In block 1, the test bank sends account #1 some ether.
|
|
|
|
tx, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey) |
|
|
|
tx, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey) |
|
|
|
block.AddTx(tx) |
|
|
|
block.AddTx(tx) |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
// In block 2, the test bank sends some more ether to account #1.
|
|
|
|
// In block 2, the test bank sends some more ether to account #1.
|
|
|
|
// acc1Addr passes it on to account #2.
|
|
|
|
// acc1Addr passes it on to account #2.
|
|
|
|
tx1, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey) |
|
|
|
tx1, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey) |
|
|
|
tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(acc1Key) |
|
|
|
tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(acc1Key) |
|
|
|
block.AddTx(tx1) |
|
|
|
block.AddTx(tx1) |
|
|
|
block.AddTx(tx2) |
|
|
|
block.AddTx(tx2) |
|
|
|