diff options
author | obscuren <geffobscura@gmail.com> | 2015-05-27 01:50:42 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-05-27 02:38:26 +0800 |
commit | c37389f19ced68c8eb3bd6589f206b8a14d9a00a (patch) | |
tree | 521de84ace66e7bd06e0074ca86e7d06eb7cfafb /core/transaction_pool_test.go | |
parent | a55f408c10ea7ed40e2bd843668b6eb6c2dc038b (diff) | |
download | dexon-c37389f19ced68c8eb3bd6589f206b8a14d9a00a.tar dexon-c37389f19ced68c8eb3bd6589f206b8a14d9a00a.tar.gz dexon-c37389f19ced68c8eb3bd6589f206b8a14d9a00a.tar.bz2 dexon-c37389f19ced68c8eb3bd6589f206b8a14d9a00a.tar.lz dexon-c37389f19ced68c8eb3bd6589f206b8a14d9a00a.tar.xz dexon-c37389f19ced68c8eb3bd6589f206b8a14d9a00a.tar.zst dexon-c37389f19ced68c8eb3bd6589f206b8a14d9a00a.zip |
core: check negative value transactions. Closes #1109
Diffstat (limited to 'core/transaction_pool_test.go')
-rw-r--r-- | core/transaction_pool_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go index 49224be5b..d6ea4a2a9 100644 --- a/core/transaction_pool_test.go +++ b/core/transaction_pool_test.go @@ -138,3 +138,17 @@ func TestRemoveTx(t *testing.T) { t.Error("expected txs to be 0, got", len(pool.txs)) } } + +func TestNegativeValue(t *testing.T) { + pool, key := setupTxPool() + + tx := transaction() + tx.Value().Set(big.NewInt(-1)) + tx.SignECDSA(key) + from, _ := tx.From() + pool.currentState().AddBalance(from, big.NewInt(1)) + err := pool.Add(tx) + if err != ErrNegativeValue { + t.Error("expected", ErrNegativeValue, "got", err) + } +} |