Fix lint and build

pull/1672/head
Rongjian Lan 5 years ago
parent b3df7e1fa6
commit 301706771c
  1. 8
      node/node_handler_test.go
  2. 4
      node/staking_test.go
  3. 4
      node/worker/worker_test.go
  4. 5
      staking/types/messages.go
  5. 1638
      test.txt
  6. 10
      test/chain/main.go

@ -30,8 +30,8 @@ func TestAddNewBlock(t *testing.T) {
nodeconfig.GetShardConfig(0).SetNetworkType(nodeconfig.Devnet)
node := New(host, consensus, testDBFactory, false)
selectedTxs := node.getTransactionsForNewBlock(common.Address{})
node.Worker.CommitTransactions(selectedTxs, common.Address{})
selectedTxs, selectedStakingTxs := node.getTransactionsForNewBlock(common.Address{})
node.Worker.CommitTransactions(selectedTxs, selectedStakingTxs, common.Address{})
block, _ := node.Worker.FinalizeNewBlock([]byte{}, []byte{}, 0, common.Address{}, nil, nil)
err = node.AddNewBlock(block)
@ -59,8 +59,8 @@ func TestVerifyNewBlock(t *testing.T) {
}
node := New(host, consensus, testDBFactory, false)
selectedTxs := node.getTransactionsForNewBlock(common.Address{})
node.Worker.CommitTransactions(selectedTxs, common.Address{})
selectedTxs, selectedStakingTxs := node.getTransactionsForNewBlock(common.Address{})
node.Worker.CommitTransactions(selectedTxs, selectedStakingTxs, common.Address{})
block, _ := node.Worker.FinalizeNewBlock([]byte{}, []byte{}, 0, common.Address{}, nil, nil)
if err := node.VerifyNewBlock(block); err != nil {

@ -41,8 +41,8 @@ func TestUpdateStakingList(t *testing.T) {
node.BlockPeriod = 8 * time.Second
for i := 0; i < 1; i++ {
selectedTxs := node.getTransactionsForNewBlock(common.Address{})
node.Worker.CommitTransactions(selectedTxs, common.Address{})
selectedTxs, selectedStakingTxs := node.getTransactionsForNewBlock(common.Address{})
node.Worker.CommitTransactions(selectedTxs, selectedStakingTxs, common.Address{})
block, err := node.Worker.FinalizeNewBlock([]byte{}, []byte{}, 0, common.Address{}, nil, nil)
// The block must first be finalized before being added to the blockchain.

@ -5,6 +5,8 @@ import (
"math/rand"
"testing"
types2 "github.com/harmony-one/harmony/staking/types"
blockfactory "github.com/harmony-one/harmony/block/factory"
chain2 "github.com/harmony-one/harmony/internal/chain"
@ -75,7 +77,7 @@ func TestCommitTransactions(t *testing.T) {
tx, _ := types.SignTx(types.NewTransaction(baseNonce, testBankAddress, uint32(0), big.NewInt(int64(denominations.One*randAmount)), params.TxGas, nil, nil), types.HomesteadSigner{}, testBankKey)
// Commit the tx to the worker
err := worker.CommitTransactions(types.Transactions{tx}, testBankAddress)
err := worker.CommitTransactions(types.Transactions{tx}, types2.StakingTransactions{}, testBankAddress)
if err != nil {
t.Error(err)
}

@ -26,5 +26,8 @@ type MsgCreateValidator struct {
Amount big.Int `json:"amount" yaml:"amount"`
}
func (msg MsgCreateValidator) Type() string { return "create_validator" }
// Type ...
func (msg MsgCreateValidator) Type() string { return "create_validator" }
// Signer ...
func (msg MsgCreateValidator) Signer() common.Address { return msg.Address }

1638
test.txt

File diff suppressed because it is too large Load Diff

@ -6,6 +6,8 @@ import (
"log"
"math/big"
types2 "github.com/harmony-one/harmony/staking/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
@ -127,7 +129,7 @@ func fundFaucetContract(chain *core.BlockChain) {
amount := 720000
tx, _ := types.SignTx(types.NewTransaction(nonce+uint64(4), StakingAddress, 0, big.NewInt(int64(amount)), params.TxGas, nil, nil), types.HomesteadSigner{}, FaucetPriKey)
txs = append(txs, tx)
err := contractworker.CommitTransactions(txs, testUserAddress)
err := contractworker.CommitTransactions(txs, types2.StakingTransactions{}, testUserAddress)
if err != nil {
fmt.Println(err)
}
@ -165,7 +167,7 @@ func callFaucetContractToFundAnAddress(chain *core.BlockChain) {
callEnc = append(callEnc, paddedAddress...)
callfaucettx, _ := types.SignTx(types.NewTransaction(nonce+uint64(5), faucetContractAddress, 0, big.NewInt(0), params.TxGasContractCreation*10, nil, callEnc), types.HomesteadSigner{}, FaucetPriKey)
err = contractworker.CommitTransactions(types.Transactions{callfaucettx}, testUserAddress)
err = contractworker.CommitTransactions(types.Transactions{callfaucettx}, types2.StakingTransactions{}, testUserAddress)
if err != nil {
fmt.Println(err)
}
@ -243,7 +245,7 @@ func playStaking(chain *core.BlockChain) {
tx, _ := types.SignTx(types.NewTransaction(0, stakeContractAddress, 0, big.NewInt(int64(stake)), params.TxGas*5, nil, callEncl), types.HomesteadSigner{}, allRandomUserKey[i])
stakingtxns = append(stakingtxns, tx)
}
err = contractworker.CommitTransactions(stakingtxns, common.Address{})
err = contractworker.CommitTransactions(stakingtxns, types2.StakingTransactions{}, common.Address{})
if err != nil {
fmt.Println(err)
@ -301,7 +303,7 @@ func playWithdrawStaking(chain *core.BlockChain) {
withdrawstakingtxns = append(withdrawstakingtxns, tx)
}
err = contractworker.CommitTransactions(withdrawstakingtxns, common.Address{})
err = contractworker.CommitTransactions(withdrawstakingtxns, types2.StakingTransactions{}, common.Address{})
if err != nil {
fmt.Println("error:")
fmt.Println(err)

Loading…
Cancel
Save