Merge pull request #4011 from LeoHChen/fix_travis_build

[ci] fix travis build
pull/4013/head
Leo Chen 3 years ago committed by GitHub
commit 5311117733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      api/proto/message/message.pb.go
  2. 1
      api/proto/message/message.proto
  3. 5
      api/service/legacysync/downloader/proto/downloader.pb.go
  4. 1
      api/service/legacysync/downloader/proto/downloader.proto
  5. 90
      core/tx_pool_test.go
  6. 4
      p2p/stream/protocols/sync/message/msg.pb.go
  7. 2
      p2p/stream/protocols/sync/message/msg.proto

@ -1115,8 +1115,9 @@ var file_message_proto_rawDesc = []byte{
0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x30, 0x0a, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x30, 0x0a,
0x07, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x10, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x07, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x10, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x11, 0x2e, 0x6d, 0x65, 0x73, 0x67, 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x11, 0x2e, 0x6d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x3b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

@ -1,5 +1,6 @@
syntax = "proto3"; syntax = "proto3";
package message; package message;
option go_package="./;message";
// Client is the service used for any client-facing requests. // Client is the service used for any client-facing requests.

@ -373,8 +373,9 @@ var file_downloader_proto_rawDesc = []byte{
0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61,
0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x64, 0x6f, 0x77, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x64, 0x6f, 0x77,
0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64,
0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d,
0x6f, 0x74, 0x6f, 0x33, 0x2e, 0x2f, 0x3b, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

@ -1,6 +1,7 @@
syntax = "proto3"; syntax = "proto3";
package downloader; package downloader;
option go_package="./;downloader";
// Downloader is the service used for downloading/sycning blocks. // Downloader is the service used for downloading/sycning blocks.
service Downloader { service Downloader {

@ -52,7 +52,7 @@ var (
testBLSPubKey = "30b2c38b1316da91e068ac3bd8751c0901ef6c02a1d58bc712104918302c6ed03d5894671d0c816dad2b4d303320f202" testBLSPubKey = "30b2c38b1316da91e068ac3bd8751c0901ef6c02a1d58bc712104918302c6ed03d5894671d0c816dad2b4d303320f202"
testBLSPrvKey = "c6d7603520311f7a4e6aac0b26701fc433b75b38df504cd416ef2b900cd66205" testBLSPrvKey = "c6d7603520311f7a4e6aac0b26701fc433b75b38df504cd416ef2b900cd66205"
gasPrice = big.NewInt(1e9) gasPrice = big.NewInt(3e10)
gasLimit = big.NewInt(int64(params.TxGasValidatorCreation)) gasLimit = big.NewInt(int64(params.TxGasValidatorCreation))
cost = big.NewInt(1).Mul(gasPrice, gasLimit) cost = big.NewInt(1).Mul(gasPrice, gasLimit)
dummyErrorSink = types.NewTransactionErrorSink() dummyErrorSink = types.NewTransactionErrorSink()
@ -127,13 +127,13 @@ func stakingCreateValidatorTransaction(key *ecdsa.PrivateKey) (*staking.StakingT
} }
} }
gasPrice := big.NewInt(1000000000) gasPrice := big.NewInt(30000000000)
tx, _ := staking.NewStakingTransaction(0, 1e10, gasPrice, stakePayloadMaker) tx, _ := staking.NewStakingTransaction(0, 1e10, gasPrice, stakePayloadMaker)
return staking.Sign(tx, staking.NewEIP155Signer(tx.ChainID()), key) return staking.Sign(tx, staking.NewEIP155Signer(tx.ChainID()), key)
} }
func transaction(shardID uint32, nonce uint64, gaslimit uint64, key *ecdsa.PrivateKey) types.PoolTransaction { func transaction(shardID uint32, nonce uint64, gaslimit uint64, key *ecdsa.PrivateKey) types.PoolTransaction {
return pricedTransaction(shardID, nonce, gaslimit, big.NewInt(1000000000), key) return pricedTransaction(shardID, nonce, gaslimit, big.NewInt(30000000000), key)
} }
func pricedTransaction(shardID uint32, nonce uint64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey) types.PoolTransaction { func pricedTransaction(shardID uint32, nonce uint64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey) types.PoolTransaction {
@ -307,7 +307,7 @@ func TestInvalidTransactions(t *testing.T) {
} }
tx = transaction(0, 1, 100000, key) tx = transaction(0, 1, 100000, key)
pool.gasPrice = big.NewInt(1000000000000) pool.gasPrice = big.NewInt(300000000000)
if err := pool.AddRemote(tx); err != ErrUnderpriced { if err := pool.AddRemote(tx); err != ErrUnderpriced {
t.Error("expected", ErrUnderpriced, "got", err) t.Error("expected", ErrUnderpriced, "got", err)
} }
@ -439,7 +439,7 @@ func TestMixedTransactions(t *testing.T) {
goodFromKey, _ := crypto.GenerateKey() goodFromKey, _ := crypto.GenerateKey()
tx := transaction(0, 0, 25000, goodFromKey) tx := transaction(0, 0, 25000, goodFromKey)
txAddr, _ := deriveSender(tx) txAddr, _ := deriveSender(tx)
pool.currentState.AddBalance(txAddr, big.NewInt(50100000000000)) pool.currentState.AddBalance(txAddr, big.NewInt(1503000000000000))
errs := pool.AddRemotes(types.PoolTransactions{stx, tx}) errs := pool.AddRemotes(types.PoolTransactions{stx, tx})
for _, err := range errs { for _, err := range errs {
@ -472,8 +472,8 @@ func TestBlacklistedTransactions(t *testing.T) {
goodFromAcc, _ := deriveSender(goodTx) goodFromAcc, _ := deriveSender(goodTx)
// Fund from accounts // Fund from accounts
pool.currentState.AddBalance(bannedFromAcc, big.NewInt(50100000000000)) pool.currentState.AddBalance(bannedFromAcc, big.NewInt(1503000000000000))
pool.currentState.AddBalance(goodFromAcc, big.NewInt(50100000000000)) pool.currentState.AddBalance(goodFromAcc, big.NewInt(1503000000000000))
DefaultTxPoolConfig.Blacklist[bannedToAcc] = struct{}{} DefaultTxPoolConfig.Blacklist[bannedToAcc] = struct{}{}
err := pool.AddRemotes(types.PoolTransactions{badTx}) err := pool.AddRemotes(types.PoolTransactions{badTx})
@ -506,7 +506,7 @@ func TestTransactionQueue(t *testing.T) {
tx := transaction(0, 0, 100, key) tx := transaction(0, 0, 100, key)
from, _ := deriveSender(tx) from, _ := deriveSender(tx)
pool.currentState.AddBalance(from, big.NewInt(1000000000000)) pool.currentState.AddBalance(from, big.NewInt(30000000000000))
pool.lockedReset(nil, nil) pool.lockedReset(nil, nil)
pool.enqueueTx(tx) pool.enqueueTx(tx)
@ -535,7 +535,7 @@ func TestTransactionQueue(t *testing.T) {
tx2 := transaction(0, 10, 100, key) tx2 := transaction(0, 10, 100, key)
tx3 := transaction(0, 11, 100, key) tx3 := transaction(0, 11, 100, key)
from, _ = deriveSender(tx1) from, _ = deriveSender(tx1)
pool.currentState.AddBalance(from, big.NewInt(1000000000000)) pool.currentState.AddBalance(from, big.NewInt(30000000000000))
pool.lockedReset(nil, nil) pool.lockedReset(nil, nil)
pool.enqueueTx(tx1) pool.enqueueTx(tx1)
@ -577,7 +577,7 @@ func TestTransactionChainFork(t *testing.T) {
addr := crypto.PubkeyToAddress(key.PublicKey) addr := crypto.PubkeyToAddress(key.PublicKey)
resetState := func() { resetState := func() {
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase())) statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb.AddBalance(addr, big.NewInt(9000000000000000)) statedb.AddBalance(addr, big.NewInt(9000000000000000000))
pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed)} pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed)}
pool.lockedReset(nil, nil) pool.lockedReset(nil, nil)
@ -606,7 +606,7 @@ func TestTransactionDoubleNonce(t *testing.T) {
addr := crypto.PubkeyToAddress(key.PublicKey) addr := crypto.PubkeyToAddress(key.PublicKey)
resetState := func() { resetState := func() {
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase())) statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb.AddBalance(addr, big.NewInt(100000000000000000)) statedb.AddBalance(addr, big.NewInt(1000000000000000000))
pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed)} pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed)}
pool.lockedReset(nil, nil) pool.lockedReset(nil, nil)
@ -615,13 +615,13 @@ func TestTransactionDoubleNonce(t *testing.T) {
signer := types.HomesteadSigner{} signer := types.HomesteadSigner{}
tx1, _ := types.SignTx( tx1, _ := types.SignTx(
types.NewTransaction(0, common.Address{}, 0, big.NewInt(100), 100000, big.NewInt(1000000000), nil), types.NewTransaction(0, common.Address{}, 0, big.NewInt(100), 100000, big.NewInt(30000000000), nil),
signer, key) signer, key)
tx2, _ := types.SignTx( tx2, _ := types.SignTx(
types.NewTransaction(0, common.Address{}, 0, big.NewInt(100), 1000000, big.NewInt(2000000000), nil), types.NewTransaction(0, common.Address{}, 0, big.NewInt(100), 1000000, big.NewInt(31000000000), nil),
signer, key) signer, key)
tx3, _ := types.SignTx( tx3, _ := types.SignTx(
types.NewTransaction(0, common.Address{}, 0, big.NewInt(100), 1000000, big.NewInt(1000000000), nil), types.NewTransaction(0, common.Address{}, 0, big.NewInt(100), 1000000, big.NewInt(30000000000), nil),
signer, key) signer, key)
// Add the first two transaction, ensure higher priced stays only // Add the first two transaction, ensure higher priced stays only
@ -660,7 +660,7 @@ func TestTransactionMissingNonce(t *testing.T) {
defer pool.Stop() defer pool.Stop()
addr := crypto.PubkeyToAddress(key.PublicKey) addr := crypto.PubkeyToAddress(key.PublicKey)
pool.currentState.AddBalance(addr, big.NewInt(100100000000000)) pool.currentState.AddBalance(addr, big.NewInt(3003000000000000))
tx := transaction(0, 1, 100000, key) tx := transaction(0, 1, 100000, key)
if _, err := pool.add(tx, false); err != nil { if _, err := pool.add(tx, false); err != nil {
t.Error("didn't expect error", err) t.Error("didn't expect error", err)
@ -685,7 +685,7 @@ func TestTransactionNonceRecovery(t *testing.T) {
addr := crypto.PubkeyToAddress(key.PublicKey) addr := crypto.PubkeyToAddress(key.PublicKey)
pool.currentState.SetNonce(addr, n) pool.currentState.SetNonce(addr, n)
pool.currentState.AddBalance(addr, big.NewInt(100100000000000)) pool.currentState.AddBalance(addr, big.NewInt(3003000000000000))
pool.lockedReset(nil, nil) pool.lockedReset(nil, nil)
tx := transaction(0, n, 100000, key) tx := transaction(0, n, 100000, key)
@ -710,7 +710,7 @@ func TestTransactionDropping(t *testing.T) {
defer pool.Stop() defer pool.Stop()
account, _ := deriveSender(transaction(0, 0, 0, key)) account, _ := deriveSender(transaction(0, 0, 0, key))
pool.currentState.AddBalance(account, big.NewInt(1000000000000)) pool.currentState.AddBalance(account, big.NewInt(30000000000000))
// Add some pending and some queued transactions // Add some pending and some queued transactions
var ( var (
@ -749,26 +749,26 @@ func TestTransactionDropping(t *testing.T) {
t.Errorf("total transaction mismatch: have %d, want %d", pool.all.Count(), 6) t.Errorf("total transaction mismatch: have %d, want %d", pool.all.Count(), 6)
} }
// Reduce the balance of the account, and check that invalidated transactions are dropped // Reduce the balance of the account, and check that invalidated transactions are dropped
pool.currentState.AddBalance(account, big.NewInt(-650000000000)) pool.currentState.AddBalance(account, big.NewInt(-23000000000000))
pool.lockedReset(nil, nil) pool.lockedReset(nil, nil)
if _, ok := pool.pending[account].txs.items[tx0.Nonce()]; !ok { if _, ok := pool.pending[account].txs.items[tx0.Nonce()]; !ok {
t.Errorf("funded pending transaction missing: %v", tx0) t.Errorf("funded pending transaction missing: %v", tx0)
} }
if _, ok := pool.pending[account].txs.items[tx1.Nonce()]; !ok { if _, ok := pool.pending[account].txs.items[tx1.Nonce()]; !ok {
t.Errorf("funded pending transaction missing: %v", tx0) t.Errorf("funded pending transaction missing: %v", tx1)
} }
if _, ok := pool.pending[account].txs.items[tx2.Nonce()]; ok { if _, ok := pool.pending[account].txs.items[tx2.Nonce()]; ok {
t.Errorf("out-of-fund pending transaction present: %v", tx1) t.Errorf("out-of-fund pending transaction present: %v", tx2)
} }
if _, ok := pool.queue[account].txs.items[tx10.Nonce()]; !ok { if _, ok := pool.queue[account].txs.items[tx10.Nonce()]; !ok {
t.Errorf("funded queued transaction missing: %v", tx10) t.Errorf("funded queued transaction missing: %v", tx10)
} }
if _, ok := pool.queue[account].txs.items[tx11.Nonce()]; !ok { if _, ok := pool.queue[account].txs.items[tx11.Nonce()]; !ok {
t.Errorf("funded queued transaction missing: %v", tx10) t.Errorf("funded queued transaction missing: %v", tx11)
} }
if _, ok := pool.queue[account].txs.items[tx12.Nonce()]; ok { if _, ok := pool.queue[account].txs.items[tx12.Nonce()]; ok {
t.Errorf("out-of-fund queued transaction present: %v", tx11) t.Errorf("out-of-fund queued transaction present: %v", tx12)
} }
if pool.all.Count() != 4 { if pool.all.Count() != 4 {
t.Errorf("total transaction mismatch: have %d, want %d", pool.all.Count(), 4) t.Errorf("total transaction mismatch: have %d, want %d", pool.all.Count(), 4)
@ -815,7 +815,7 @@ func TestTransactionPostponing(t *testing.T) {
keys[i], _ = crypto.GenerateKey() keys[i], _ = crypto.GenerateKey()
accs[i] = crypto.PubkeyToAddress(keys[i].PublicKey) accs[i] = crypto.PubkeyToAddress(keys[i].PublicKey)
pool.currentState.AddBalance(crypto.PubkeyToAddress(keys[i].PublicKey), big.NewInt(50100000000000)) pool.currentState.AddBalance(crypto.PubkeyToAddress(keys[i].PublicKey), big.NewInt(1500100000000000))
} }
// Add a batch consecutive pending transactions for validation // Add a batch consecutive pending transactions for validation
txs := types.PoolTransactions{} txs := types.PoolTransactions{}
@ -858,7 +858,7 @@ func TestTransactionPostponing(t *testing.T) {
} }
// Reduce the balance of the account, and check that transactions are reorganised // Reduce the balance of the account, and check that transactions are reorganised
for _, addr := range accs { for _, addr := range accs {
pool.currentState.AddBalance(addr, big.NewInt(-1)) pool.currentState.AddBalance(addr, big.NewInt(-30))
} }
pool.lockedReset(nil, nil) pool.lockedReset(nil, nil)
@ -922,7 +922,7 @@ func TestTransactionQueueAccountLimiting(t *testing.T) {
defer pool.Stop() defer pool.Stop()
account, _ := deriveSender(transaction(0, 0, 0, key)) account, _ := deriveSender(transaction(0, 0, 0, key))
pool.currentState.AddBalance(account, big.NewInt(900000000000000)) pool.currentState.AddBalance(account, big.NewInt(9000000000000000000))
// Keep queuing up transactions and make sure all above a limit are dropped // Keep queuing up transactions and make sure all above a limit are dropped
for i := uint64(1); i <= testTxPoolConfig.AccountQueue+5; i++ { for i := uint64(1); i <= testTxPoolConfig.AccountQueue+5; i++ {
@ -977,7 +977,7 @@ func testTransactionQueueGlobalLimiting(t *testing.T, nolocals bool) {
keys := make([]*ecdsa.PrivateKey, 5) keys := make([]*ecdsa.PrivateKey, 5)
for i := 0; i < len(keys); i++ { for i := 0; i < len(keys); i++ {
keys[i], _ = crypto.GenerateKey() keys[i], _ = crypto.GenerateKey()
pool.currentState.AddBalance(crypto.PubkeyToAddress(keys[i].PublicKey), big.NewInt(1000000000000000)) pool.currentState.AddBalance(crypto.PubkeyToAddress(keys[i].PublicKey), big.NewInt(30000000000000000))
} }
local := keys[len(keys)-1] local := keys[len(keys)-1]
@ -1067,14 +1067,14 @@ func testTransactionQueueTimeLimiting(t *testing.T, nolocals bool) {
local, _ := crypto.GenerateKey() local, _ := crypto.GenerateKey()
remote, _ := crypto.GenerateKey() remote, _ := crypto.GenerateKey()
pool.currentState.AddBalance(crypto.PubkeyToAddress(local.PublicKey), big.NewInt(900000000000000)) pool.currentState.AddBalance(crypto.PubkeyToAddress(local.PublicKey), big.NewInt(9000000000000000000))
pool.currentState.AddBalance(crypto.PubkeyToAddress(remote.PublicKey), big.NewInt(900000000000000)) pool.currentState.AddBalance(crypto.PubkeyToAddress(remote.PublicKey), big.NewInt(9000000000000000000))
// Add the two transactions and ensure they both are queued up // Add the two transactions and ensure they both are queued up
if err := pool.AddLocal(pricedTransaction(0, 1, 100000, big.NewInt(1000000000), local)); err != nil { if err := pool.AddLocal(pricedTransaction(0, 1, 100000, big.NewInt(100000000000), local)); err != nil {
t.Fatalf("failed to add local transaction: %v", err) t.Fatalf("failed to add local transaction: %v", err)
} }
if err := pool.AddRemote(pricedTransaction(0, 1, 100000, big.NewInt(1000000000), remote)); err != nil { if err := pool.AddRemote(pricedTransaction(0, 1, 100000, big.NewInt(100000000000), remote)); err != nil {
t.Fatalf("failed to add remote transaction: %v", err) t.Fatalf("failed to add remote transaction: %v", err)
} }
pending, queued := pool.Stats() pending, queued := pool.Stats()
@ -1123,7 +1123,7 @@ func testTransactionLimitingEquivalency(t *testing.T, origin uint64) {
defer pool1.Stop() defer pool1.Stop()
account1, _ := deriveSender(transaction(0, 0, 0, key1)) account1, _ := deriveSender(transaction(0, 0, 0, key1))
pool1.currentState.AddBalance(account1, big.NewInt(9000000000000000)) pool1.currentState.AddBalance(account1, big.NewInt(9000000000000000000))
for i := uint64(0); i < testTxPoolConfig.AccountQueue+5; i++ { for i := uint64(0); i < testTxPoolConfig.AccountQueue+5; i++ {
if err := pool1.AddRemote(transaction(0, origin+i, 100000, key1)); err != nil { if err := pool1.AddRemote(transaction(0, origin+i, 100000, key1)); err != nil {
@ -1135,7 +1135,7 @@ func testTransactionLimitingEquivalency(t *testing.T, origin uint64) {
defer pool2.Stop() defer pool2.Stop()
account2, _ := deriveSender(transaction(0, 0, 0, key2)) account2, _ := deriveSender(transaction(0, 0, 0, key2))
pool2.currentState.AddBalance(account2, big.NewInt(9000000000000000)) pool2.currentState.AddBalance(account2, big.NewInt(9000000000000000000))
txs := types.PoolTransactions{} txs := types.PoolTransactions{}
for i := uint64(0); i < testTxPoolConfig.AccountQueue+5; i++ { for i := uint64(0); i < testTxPoolConfig.AccountQueue+5; i++ {
@ -1308,12 +1308,12 @@ func TestTransactionPoolRepricingKeepsLocals(t *testing.T) {
// Create transaction (both pending and queued) with a linearly growing gasprice // Create transaction (both pending and queued) with a linearly growing gasprice
for i := uint64(0); i < 500; i++ { for i := uint64(0); i < 500; i++ {
// Add pending // Add pending
pTx := pricedTransaction(0, i, 100000, big.NewInt(int64(i*1000000000)), keys[2]) pTx := pricedTransaction(0, i, 100000, big.NewInt(int64(30000000000+i*1000000000)), keys[2])
if err := pool.AddLocal(pTx); err != nil { if err := pool.AddLocal(pTx); err != nil {
t.Fatal(err) t.Fatal(err)
} }
// Add queued // Add queued
qTx := pricedTransaction(0, i+501, 100000, big.NewInt(int64(i*1000000000)), keys[2]) qTx := pricedTransaction(0, i+501, 100000, big.NewInt(int64(30000000000+i*1000000000)), keys[2])
if err := pool.AddLocal(qTx); err != nil { if err := pool.AddLocal(qTx); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -1381,20 +1381,20 @@ func testTransactionJournaling(t *testing.T, nolocals bool) {
local, _ := crypto.GenerateKey() local, _ := crypto.GenerateKey()
remote, _ := crypto.GenerateKey() remote, _ := crypto.GenerateKey()
pool.currentState.AddBalance(crypto.PubkeyToAddress(local.PublicKey), big.NewInt(900000000000000)) pool.currentState.AddBalance(crypto.PubkeyToAddress(local.PublicKey), big.NewInt(9000000000000000000))
pool.currentState.AddBalance(crypto.PubkeyToAddress(remote.PublicKey), big.NewInt(900000000000000)) pool.currentState.AddBalance(crypto.PubkeyToAddress(remote.PublicKey), big.NewInt(9000000000000000000))
// Add three local and a remote transactions and ensure they are queued up // Add three local and a remote transactions and ensure they are queued up
if err := pool.AddLocal(pricedTransaction(0, 0, 100000, big.NewInt(1000000000), local)); err != nil { if err := pool.AddLocal(pricedTransaction(0, 0, 100000, big.NewInt(30000000000), local)); err != nil {
t.Fatalf("failed to add local transaction: %v", err) t.Fatalf("failed to add local transaction: %v", err)
} }
if err := pool.AddLocal(pricedTransaction(0, 1, 100000, big.NewInt(1000000000), local)); err != nil { if err := pool.AddLocal(pricedTransaction(0, 1, 100000, big.NewInt(30000000000), local)); err != nil {
t.Fatalf("failed to add local transaction: %v", err) t.Fatalf("failed to add local transaction: %v", err)
} }
if err := pool.AddLocal(pricedTransaction(0, 2, 100000, big.NewInt(1000000000), local)); err != nil { if err := pool.AddLocal(pricedTransaction(0, 2, 100000, big.NewInt(30000000000), local)); err != nil {
t.Fatalf("failed to add local transaction: %v", err) t.Fatalf("failed to add local transaction: %v", err)
} }
if err := pool.AddRemote(pricedTransaction(0, 0, 100000, big.NewInt(1000000000), remote)); err != nil { if err := pool.AddRemote(pricedTransaction(0, 0, 100000, big.NewInt(30000000000), remote)); err != nil {
t.Fatalf("failed to add remote transaction: %v", err) t.Fatalf("failed to add remote transaction: %v", err)
} }
pending, queued := pool.Stats() pending, queued := pool.Stats()
@ -1475,15 +1475,15 @@ func TestTransactionStatusCheck(t *testing.T) {
keys := make([]*ecdsa.PrivateKey, 3) keys := make([]*ecdsa.PrivateKey, 3)
for i := 0; i < len(keys); i++ { for i := 0; i < len(keys); i++ {
keys[i], _ = crypto.GenerateKey() keys[i], _ = crypto.GenerateKey()
pool.currentState.AddBalance(crypto.PubkeyToAddress(keys[i].PublicKey), big.NewInt(9000000000000000)) pool.currentState.AddBalance(crypto.PubkeyToAddress(keys[i].PublicKey), big.NewInt(9000000000000000000))
} }
// Generate and queue a batch of transactions, both pending and queued // Generate and queue a batch of transactions, both pending and queued
txs := types.PoolTransactions{} txs := types.PoolTransactions{}
txs = append(txs, pricedTransaction(0, 0, 100000, big.NewInt(1000000000), keys[0])) // Pending only txs = append(txs, pricedTransaction(0, 0, 100000, big.NewInt(30000000000), keys[0])) // Pending only
txs = append(txs, pricedTransaction(0, 0, 100000, big.NewInt(1000000000), keys[1])) // Pending and queued txs = append(txs, pricedTransaction(0, 0, 100000, big.NewInt(30000000000), keys[1])) // Pending and queued
txs = append(txs, pricedTransaction(0, 2, 100000, big.NewInt(1000000000), keys[1])) txs = append(txs, pricedTransaction(0, 2, 100000, big.NewInt(30000000000), keys[1]))
txs = append(txs, pricedTransaction(0, 2, 100000, big.NewInt(1000000000), keys[2])) // Queued only txs = append(txs, pricedTransaction(0, 2, 100000, big.NewInt(30000000000), keys[2])) // Queued only
// Import the transaction and ensure they are correctly added // Import the transaction and ensure they are correctly added
pool.AddRemotes(txs) pool.AddRemotes(txs)

@ -896,8 +896,8 @@ var file_msg_proto_rawDesc = []byte{
0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x6c, 0x6f,
0x63, 0x6b, 0x73, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d,
0x69, 0x74, 0x5f, 0x73, 0x69, 0x67, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x63, 0x6f, 0x69, 0x74, 0x5f, 0x73, 0x69, 0x67, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x63, 0x6f,
0x6d, 0x6d, 0x69, 0x74, 0x53, 0x69, 0x67, 0x42, 0x09, 0x5a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x69, 0x67, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x3b, 0x6d, 0x65,
0x67, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x73, 0x73, 0x61, 0x67, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

@ -1,7 +1,7 @@
syntax = "proto3"; syntax = "proto3";
package harmony.stream.sync.message ; package harmony.stream.sync.message ;
option go_package = "message"; option go_package = "./;message";
message Message { message Message {
oneof req_or_resp { oneof req_or_resp {

Loading…
Cancel
Save