move blocknumber to blockhash

This commit is contained in:
Nguyen Sy Thanh Son 2018-07-17 08:41:16 +00:00
parent 5de2a2da3f
commit a7bd5d29de
2 changed files with 21 additions and 7 deletions

View file

@ -75,7 +75,10 @@ func GetSignersFromContract(addrBlockSigner common.Address, client bind.Contract
return nil, err
}
opts := new(bind.CallOpts)
addrs, err := blockSigner.GetSigners(opts, new(big.Int).SetUint64(blockNumber))
// TODO: let move from blockNumber to blockHash
// addrs, err := blockSigner.GetSigners(opts, new(big.Int).SetUint64(blockNumber))
log.Error("Should replace blockNumber to blockHash", blockNumber)
addrs, err := blockSigner.GetSigners(opts, [32]byte{})
if err != nil {
log.Error("Fail get block signers", "error", err)
return nil, err

View file

@ -9,11 +9,11 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/common"
// "github.com/ethereum/go-ethereum/contracts"
// "github.com/ethereum/go-ethereum/contracts/validator/contract"
"github.com/ethereum/go-ethereum/contracts"
"github.com/ethereum/go-ethereum/contracts/validator/contract"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
// "math/rand"
"math/rand"
)
var (
@ -65,7 +65,6 @@ func TestValidator(t *testing.T) {
contractBackend.Commit()
}
/*
func TestRewardBalance(t *testing.T) {
contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{
acc1Addr: {Balance: new(big.Int).SetUint64(10000000)},
@ -77,7 +76,20 @@ func TestRewardBalance(t *testing.T) {
accounts := []*bind.TransactOpts{acc1Opts, acc2Opts}
transactOpts := bind.NewKeyedTransactor(acc1Key)
validatorAddr, _, baseValidator, err := contract.DeployTomoValidator(transactOpts, contractBackend, big.NewInt(50000), big.NewInt(99), big.NewInt(100), big.NewInt(100))
// validatorAddr, _, baseValidator, err := contract.DeployTomoValidator(transactOpts, contractBackend, big.NewInt(50000), big.NewInt(99), big.NewInt(100), big.NewInt(100))
validatorCap := new(big.Int)
validatorCap.SetString("50000000000000000000000", 10)
validatorAddr, _, baseValidator, err := contract.DeployTomoValidator(
transactOpts,
contractBackend,
[]common.Address{addr},
[]*big.Int{validatorCap},
addr,
big.NewInt(50000),
big.NewInt(99),
big.NewInt(100),
big.NewInt(100),
)
if err != nil {
t.Fatalf("can't deploy root registry: %v", err)
}
@ -146,4 +158,3 @@ func TestRewardBalance(t *testing.T) {
}
}
*/