diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-08-17 20:01:41 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-09-22 02:33:28 +0800 |
commit | eaa4473dbd4ad404b85f8f0f63b0418a782351b4 (patch) | |
tree | 27eabb671346c279969caafe28d25a44aef0f9a0 /core/transaction_pool_test.go | |
parent | 12c0afe4fe9f284dd10a80af7744102dac8bf06b (diff) | |
download | dexon-eaa4473dbd4ad404b85f8f0f63b0418a782351b4.tar dexon-eaa4473dbd4ad404b85f8f0f63b0418a782351b4.tar.gz dexon-eaa4473dbd4ad404b85f8f0f63b0418a782351b4.tar.bz2 dexon-eaa4473dbd4ad404b85f8f0f63b0418a782351b4.tar.lz dexon-eaa4473dbd4ad404b85f8f0f63b0418a782351b4.tar.xz dexon-eaa4473dbd4ad404b85f8f0f63b0418a782351b4.tar.zst dexon-eaa4473dbd4ad404b85f8f0f63b0418a782351b4.zip |
core, core/types: readd transactions after chain re-org
Added a `Difference` method to `types.Transactions` which sets the
receiver to the difference of a to b (NOTE: not a **and** b).
Transaction pool subscribes to RemovedTransactionEvent adding back to
those potential missing from the chain.
When a chain re-org occurs remove any transactions that were removed
from the canonical chain during the re-org as well as the receipts that
were generated in the process.
Closes #1746
Diffstat (limited to 'core/transaction_pool_test.go')
-rw-r--r-- | core/transaction_pool_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go index d9267cc43..37cd20c96 100644 --- a/core/transaction_pool_test.go +++ b/core/transaction_pool_test.go @@ -238,3 +238,15 @@ func TestNonceRecovery(t *testing.T) { t.Errorf("expected nonce to be %d, got %d", n+1, fn) } } + +func TestRemovedTxEvent(t *testing.T) { + pool, key := setupTxPool() + tx := transaction(0, big.NewInt(1000000), key) + from, _ := tx.From() + pool.currentState().AddBalance(from, big.NewInt(1000000000000)) + pool.eventMux.Post(RemovedTransactionEvent{types.Transactions{tx}}) + pool.eventMux.Post(ChainHeadEvent{nil}) + if len(pool.pending) != 1 { + t.Error("expected 1 pending tx, got", len(pool.pending)) + } +} |