aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain_test.go
diff options
context:
space:
mode:
authorbojie <bojie@dexon.org>2019-01-14 20:42:15 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:21 +0800
commitf587289bc3d5f679c6e92acb817a40a88a19e970 (patch)
tree55b30e09ee4222973fc935ba83c08ac6f13a24dd /core/blockchain_test.go
parent2b03b31d46e166e70ea82b806db47bb6408282e3 (diff)
downloadgo-tangerine-f587289bc3d5f679c6e92acb817a40a88a19e970.tar
go-tangerine-f587289bc3d5f679c6e92acb817a40a88a19e970.tar.gz
go-tangerine-f587289bc3d5f679c6e92acb817a40a88a19e970.tar.bz2
go-tangerine-f587289bc3d5f679c6e92acb817a40a88a19e970.tar.lz
go-tangerine-f587289bc3d5f679c6e92acb817a40a88a19e970.tar.xz
go-tangerine-f587289bc3d5f679c6e92acb817a40a88a19e970.tar.zst
go-tangerine-f587289bc3d5f679c6e92acb817a40a88a19e970.zip
app: remove pending block logic (#149)
Diffstat (limited to 'core/blockchain_test.go')
-rw-r--r--core/blockchain_test.go38
1 files changed, 19 insertions, 19 deletions
diff --git a/core/blockchain_test.go b/core/blockchain_test.go
index a902f0032..45eb191f2 100644
--- a/core/blockchain_test.go
+++ b/core/blockchain_test.go
@@ -1626,7 +1626,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()
@@ -1672,8 +1672,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 {
@@ -1689,7 +1689,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: uint64(time.Now().UnixNano() / 1000000),
GasLimit: 10000,
@@ -1703,13 +1703,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: uint64(time.Now().UnixNano() / 1000000),
GasLimit: 10000,
@@ -1724,14 +1724,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: uint64(time.Now().UnixNano() / 1000000),
GasLimit: 10000,
@@ -1747,14 +1747,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: uint64(time.Now().UnixNano() / 1000000),
GasLimit: 10000,
@@ -1770,8 +1770,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 {
@@ -1786,7 +1786,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: uint64(time.Now().UnixNano() / 1000000),
GasLimit: 10000,
@@ -1802,8 +1802,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 {
@@ -1818,7 +1818,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: uint64(time.Now().UnixNano() / 1000000),
GasLimit: 10000,