diff options
author | bojie <bojie@dexon.org> | 2019-01-14 20:42:15 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | 2fc7f8878544bb7b46ce8357a64b9e920195a243 (patch) | |
tree | 04122d44b8461f5475fb24839dab193aece99afe /core/blockchain_test.go | |
parent | 2d9f86f9a5af14cb2058912deb490640dfd83977 (diff) | |
download | dexon-2fc7f8878544bb7b46ce8357a64b9e920195a243.tar dexon-2fc7f8878544bb7b46ce8357a64b9e920195a243.tar.gz dexon-2fc7f8878544bb7b46ce8357a64b9e920195a243.tar.bz2 dexon-2fc7f8878544bb7b46ce8357a64b9e920195a243.tar.lz dexon-2fc7f8878544bb7b46ce8357a64b9e920195a243.tar.xz dexon-2fc7f8878544bb7b46ce8357a64b9e920195a243.tar.zst dexon-2fc7f8878544bb7b46ce8357a64b9e920195a243.zip |
app: remove pending block logic (#149)
Diffstat (limited to 'core/blockchain_test.go')
-rw-r--r-- | core/blockchain_test.go | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 1c4be752c..e0e7671e1 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -1420,7 +1420,7 @@ func (d *dexconTest) Finalize(chain consensus.ChainReader, header *types.Header, return types.NewBlock(header, txs, uncles, receipts), nil } -func TestProcessPendingBlock(t *testing.T) { +func TestProcessBlock(t *testing.T) { db := ethdb.NewMemDatabase() key, err := crypto.GenerateKey() @@ -1466,8 +1466,8 @@ func TestProcessPendingBlock(t *testing.T) { } } else { witnessData := types.WitnessData{ - Root: chain.pendingBlocks[uint64(i)].block.Root(), - ReceiptHash: chain.pendingBlocks[uint64(i)].block.ReceiptHash(), + Root: chain.CurrentBlock().Root(), + ReceiptHash: chain.CurrentBlock().ReceiptHash(), } witnessDataBytes, err = rlp.EncodeToBytes(&witnessData) if err != nil { @@ -1483,7 +1483,7 @@ func TestProcessPendingBlock(t *testing.T) { t.Fatalf("sign tx error: %v", err) } - _, err = chain.ProcessPendingBlock(types.NewBlock(&types.Header{ + _, err = chain.ProcessBlock(types.NewBlock(&types.Header{ Number: new(big.Int).SetUint64(uint64(i) + 1), Time: big.NewInt(time.Now().UnixNano() / 1000000), GasLimit: 10000, @@ -1497,13 +1497,13 @@ func TestProcessPendingBlock(t *testing.T) { t.Fatalf("process pending block error: %v", err) } - if chain.CurrentBlock().NumberU64() != uint64(i) { - t.Fatalf("expect current height %v but %v", uint64(i), chain.CurrentBlock().NumberU64()) + if chain.CurrentBlock().NumberU64() != uint64(i+1) { + t.Fatalf("expect current height %v but %v", uint64(i+1), chain.CurrentBlock().NumberU64()) } } // Witness rlp decode fail. - _, err = chain.ProcessPendingBlock(types.NewBlock(&types.Header{ + _, err = chain.ProcessBlock(types.NewBlock(&types.Header{ Number: new(big.Int).SetUint64(processNum + 1), Time: big.NewInt(time.Now().UnixNano() / 1000000), GasLimit: 10000, @@ -1518,14 +1518,14 @@ func TestProcessPendingBlock(t *testing.T) { // Validate witness fail with unknown block. witnessData := types.WitnessData{ - Root: chain.pendingBlocks[processNum].block.Root(), - ReceiptHash: chain.pendingBlocks[processNum].block.ReceiptHash(), + Root: chain.CurrentBlock().Root(), + ReceiptHash: chain.CurrentBlock().ReceiptHash(), } witnessDataBytes, err := rlp.EncodeToBytes(&witnessData) if err != nil { t.Fatalf("rlp encode fail: %v", err) } - _, err = chain.ProcessPendingBlock(types.NewBlock(&types.Header{ + _, err = chain.ProcessBlock(types.NewBlock(&types.Header{ Number: new(big.Int).SetUint64(processNum + 1), Time: big.NewInt(time.Now().UnixNano() / 1000000), GasLimit: 10000, @@ -1541,14 +1541,14 @@ func TestProcessPendingBlock(t *testing.T) { // Validate witness fail with unexpected root. witnessData = types.WitnessData{ - Root: chain.pendingBlocks[processNum].block.Root(), - ReceiptHash: chain.pendingBlocks[processNum].block.ReceiptHash(), + Root: chain.CurrentBlock().Root(), + ReceiptHash: chain.CurrentBlock().ReceiptHash(), } witnessDataBytes, err = rlp.EncodeToBytes(&witnessData) if err != nil { t.Fatalf("rlp encode fail: %v", err) } - _, err = chain.ProcessPendingBlock(types.NewBlock(&types.Header{ + _, err = chain.ProcessBlock(types.NewBlock(&types.Header{ Number: new(big.Int).SetUint64(processNum + 1), Time: big.NewInt(time.Now().UnixNano() / 1000000), GasLimit: 10000, @@ -1564,8 +1564,8 @@ func TestProcessPendingBlock(t *testing.T) { // Apply transaction fail with insufficient fund. witnessData = types.WitnessData{ - Root: chain.pendingBlocks[processNum].block.Root(), - ReceiptHash: chain.pendingBlocks[processNum].block.ReceiptHash(), + Root: chain.CurrentBlock().Root(), + ReceiptHash: chain.CurrentBlock().ReceiptHash(), } witnessDataBytes, err = rlp.EncodeToBytes(&witnessData) if err != nil { @@ -1580,7 +1580,7 @@ func TestProcessPendingBlock(t *testing.T) { t.Fatalf("sign tx error: %v", err) } - _, err = chain.ProcessPendingBlock(types.NewBlock(&types.Header{ + _, err = chain.ProcessBlock(types.NewBlock(&types.Header{ Number: new(big.Int).SetUint64(processNum + 1), Time: big.NewInt(time.Now().UnixNano() / 1000000), GasLimit: 10000, @@ -1596,8 +1596,8 @@ func TestProcessPendingBlock(t *testing.T) { // Apply transaction fail with nonce too height. witnessData = types.WitnessData{ - Root: chain.pendingBlocks[processNum].block.Root(), - ReceiptHash: chain.pendingBlocks[processNum].block.ReceiptHash(), + Root: chain.CurrentBlock().Root(), + ReceiptHash: chain.CurrentBlock().ReceiptHash(), } witnessDataBytes, err = rlp.EncodeToBytes(&witnessData) if err != nil { @@ -1612,7 +1612,7 @@ func TestProcessPendingBlock(t *testing.T) { t.Fatalf("sign tx error: %v", err) } - _, err = chain.ProcessPendingBlock(types.NewBlock(&types.Header{ + _, err = chain.ProcessBlock(types.NewBlock(&types.Header{ Number: new(big.Int).SetUint64(processNum + 1), Time: big.NewInt(time.Now().UnixNano() / 1000000), GasLimit: 10000, |