aboutsummaryrefslogtreecommitdiffstats
path: root/core/transaction_pool_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-06-04 23:28:09 +0800
committerobscuren <geffobscura@gmail.com>2015-06-05 01:28:39 +0800
commit912cf7ba049e4bcd5e497c62bb7cb96e7502f1b9 (patch)
tree7c573e1cad38ef08c9502488d24968c122b40b85 /core/transaction_pool_test.go
parent0f51ee6c88f0697cec368d6e2c88b35cc173e37a (diff)
downloadgo-tangerine-912cf7ba049e4bcd5e497c62bb7cb96e7502f1b9.tar
go-tangerine-912cf7ba049e4bcd5e497c62bb7cb96e7502f1b9.tar.gz
go-tangerine-912cf7ba049e4bcd5e497c62bb7cb96e7502f1b9.tar.bz2
go-tangerine-912cf7ba049e4bcd5e497c62bb7cb96e7502f1b9.tar.lz
go-tangerine-912cf7ba049e4bcd5e497c62bb7cb96e7502f1b9.tar.xz
go-tangerine-912cf7ba049e4bcd5e497c62bb7cb96e7502f1b9.tar.zst
go-tangerine-912cf7ba049e4bcd5e497c62bb7cb96e7502f1b9.zip
core: added fork test & double nonce test
Diffstat (limited to 'core/transaction_pool_test.go')
-rw-r--r--core/transaction_pool_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go
index bbd5ddad4..ac297d266 100644
--- a/core/transaction_pool_test.go
+++ b/core/transaction_pool_test.go
@@ -152,3 +152,52 @@ func TestNegativeValue(t *testing.T) {
t.Error("expected", ErrNegativeValue, "got", err)
}
}
+
+func TestTransactionChainFork(t *testing.T) {
+ pool, key := setupTxPool()
+ addr := crypto.PubkeyToAddress(key.PublicKey)
+ pool.currentState().AddBalance(addr, big.NewInt(100000000000000))
+ tx := transaction()
+ tx.GasLimit = big.NewInt(100000)
+ tx.SignECDSA(key)
+
+ err := pool.add(tx)
+ if err != nil {
+ t.Error("didn't expect error", err)
+ }
+ pool.RemoveTransactions([]*types.Transaction{tx})
+
+ // reset the pool's internal state
+ pool.resetState()
+ err = pool.add(tx)
+ if err != nil {
+ t.Error("didn't expect error", err)
+ }
+}
+
+func TestTransactionDoubleNonce(t *testing.T) {
+ pool, key := setupTxPool()
+ addr := crypto.PubkeyToAddress(key.PublicKey)
+ pool.currentState().AddBalance(addr, big.NewInt(100000000000000))
+ tx := transaction()
+ tx.GasLimit = big.NewInt(100000)
+ tx.SignECDSA(key)
+
+ err := pool.add(tx)
+ if err != nil {
+ t.Error("didn't expect error", err)
+ }
+
+ tx2 := transaction()
+ tx2.GasLimit = big.NewInt(1000000)
+ tx2.SignECDSA(key)
+
+ err = pool.add(tx2)
+ if err != nil {
+ t.Error("didn't expect error", err)
+ }
+
+ if len(pool.pending) != 2 {
+ t.Error("expected 2 pending txs. Got", len(pool.pending))
+ }
+}