aboutsummaryrefslogtreecommitdiffstats
path: root/dex/app_test.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-02-25 18:27:34 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:57 +0800
commit5832a21db625bfa98a3b7909bb6996dd1fd2e4d3 (patch)
tree73f5de74fa6aa753349f00e11e989533de8a45ef /dex/app_test.go
parent6e66efc9f69d59a011215f88a0de03508d9c56ab (diff)
downloaddexon-5832a21db625bfa98a3b7909bb6996dd1fd2e4d3.tar
dexon-5832a21db625bfa98a3b7909bb6996dd1fd2e4d3.tar.gz
dexon-5832a21db625bfa98a3b7909bb6996dd1fd2e4d3.tar.bz2
dexon-5832a21db625bfa98a3b7909bb6996dd1fd2e4d3.tar.lz
dexon-5832a21db625bfa98a3b7909bb6996dd1fd2e4d3.tar.xz
dexon-5832a21db625bfa98a3b7909bb6996dd1fd2e4d3.tar.zst
dexon-5832a21db625bfa98a3b7909bb6996dd1fd2e4d3.zip
core: Fixed gas price (#205)
* core/vm: update abi * core/vm: add MinGasPrice to gov * params: Add MinGasPrice to Config * dex: SuggestPrice from Governance * test: add minGasPrice to genesis.json * core: check underpriced tx * dex: verify with gas price
Diffstat (limited to 'dex/app_test.go')
-rw-r--r--dex/app_test.go37
1 files changed, 31 insertions, 6 deletions
diff --git a/dex/app_test.go b/dex/app_test.go
index 09c61c11c..73d952f31 100644
--- a/dex/app_test.go
+++ b/dex/app_test.go
@@ -234,7 +234,7 @@ func TestVerifyBlock(t *testing.T) {
common.BytesToAddress([]byte{9}),
big.NewInt(50000000000000001),
params.TxGas,
- big.NewInt(1),
+ big.NewInt(10),
nil)
tx, err = types.SignTx(tx, signer, key)
if err != nil {
@@ -269,7 +269,7 @@ func TestVerifyBlock(t *testing.T) {
common.BytesToAddress([]byte{9}),
big.NewInt(1),
params.TxGas,
- big.NewInt(1),
+ big.NewInt(10),
make([]byte, 1))
tx, err = types.SignTx(tx, signer, key)
if err != nil {
@@ -304,7 +304,7 @@ func TestVerifyBlock(t *testing.T) {
common.BytesToAddress([]byte{9}),
big.NewInt(1),
params.TxGas,
- big.NewInt(1),
+ big.NewInt(10),
make([]byte, 1))
tx1, err = types.SignTx(tx, signer, key)
if err != nil {
@@ -317,7 +317,7 @@ func TestVerifyBlock(t *testing.T) {
common.BytesToAddress([]byte{9}),
big.NewInt(1),
params.TxGas,
- big.NewInt(1),
+ big.NewInt(10),
make([]byte, 1))
tx2, err = types.SignTx(tx, signer, key)
if err != nil {
@@ -334,6 +334,30 @@ func TestVerifyBlock(t *testing.T) {
if status != coreTypes.VerifyInvalidBlock {
t.Fatalf("verify fail expect invalid block but get %v", status)
}
+
+ // Invalid gas price.
+ tx = types.NewTransaction(
+ 0,
+ common.BytesToAddress([]byte{9}),
+ big.NewInt(1),
+ params.TxGas,
+ big.NewInt(5),
+ make([]byte, 1))
+ tx, err = types.SignTx(tx, signer, key)
+ if err != nil {
+ return
+ }
+ block.Payload, err = rlp.EncodeToBytes(types.Transactions{tx})
+ if err != nil {
+ return
+ }
+
+ // Expect invalid block.
+ status = dex.app.VerifyBlock(block)
+ if status != coreTypes.VerifyInvalidBlock {
+ t.Fatalf("verify fail expect invalid block but get %v", status)
+ }
+
}
func TestBlockConfirmed(t *testing.T) {
@@ -489,6 +513,7 @@ func newTestDexonWithGenesis(allocKey *ecdsa.PrivateKey) (*Dexon, error) {
PublicKey: crypto.FromECDSAPub(&key.PublicKey),
},
}
+ genesis.Config.Dexcon.MinGasPrice = big.NewInt(10)
chainConfig, _, err := core.SetupGenesisBlock(db, genesis)
if err != nil {
return nil, err
@@ -530,7 +555,7 @@ func addTx(dex *Dexon, nonce int, signer types.Signer, key *ecdsa.PrivateKey) (
common.BytesToAddress([]byte{9}),
big.NewInt(int64(nonce*1)),
params.TxGas,
- big.NewInt(1),
+ big.NewInt(10),
nil)
tx, err := types.SignTx(tx, signer, key)
if err != nil {
@@ -638,7 +663,7 @@ func prepareDataWithoutTxPool(dex *Dexon, key *ecdsa.PrivateKey, startNonce, txN
common.BytesToAddress([]byte{9}),
big.NewInt(int64(n*1)),
params.TxGas,
- big.NewInt(1),
+ big.NewInt(10),
nil)
tx, err = types.SignTx(tx, signer, key)
if err != nil {