Skip to content

Commit

Permalink
add tests for CheckContractAdminStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Williams committed Dec 8, 2018
1 parent eecf40e commit bd038ef
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (n *Node) CheckContractAdminStatusWrapper(conn *ethclient.Client) func(addr
}
}

func (n *Node) CheckContractAdminStatus(addr common.Address, conn *ethclient.Client) bool {
func (n *Node) CheckContractAdminStatus(addr common.Address, conn bind.ContractCaller) bool {
signerContract, err := shyft_contracts.NewValidSignersCaller(common.HexToAddress(n.config.WhisperSignersContract), conn)
if err != nil {
log.Info("Signer contract not initialized")
Expand Down
27 changes: 27 additions & 0 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ import (
"testing"
"time"

"math/big"

"github.com/ShyftNetwork/go-empyrean/accounts/abi/bind"
"github.com/ShyftNetwork/go-empyrean/accounts/abi/bind/backends"
"github.com/ShyftNetwork/go-empyrean/common"
"github.com/ShyftNetwork/go-empyrean/core"
"github.com/ShyftNetwork/go-empyrean/crypto"
"github.com/ShyftNetwork/go-empyrean/generated_bindings"
"github.com/ShyftNetwork/go-empyrean/p2p"
"github.com/ShyftNetwork/go-empyrean/rpc"
whisper "github.com/ShyftNetwork/go-empyrean/whisper/whisperv6"
Expand Down Expand Up @@ -615,3 +621,24 @@ func TestWhisperChannels(t *testing.T) {
t.Errorf("result mismatch: have %s, want %s", resp, testAddrA)
}
}

func TestCheckContractAdminStatus(t *testing.T) {
key0, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
addr0 := crypto.PubkeyToAddress(key0.PublicKey)
deployTransactor := bind.NewKeyedTransactor(key0)
backend := backends.NewSimulatedBackend(core.GenesisAlloc{addr0: {Balance: big.NewInt(1000000000)}}, 10000000)
addr, _, _, err := shyft_contracts.DeployValidSigners(deployTransactor, backend)
if err != nil {
t.Errorf("Deploy Valid Signers Contract failed ", err)
}
t.Log("add is ", addr)
stack, err := New(testNodeConfig())
if err != nil {
t.Fatalf("failed to create protocol stack: %v", err)
}
result := stack.CheckContractAdminStatus(addr0, backend)

if result != false {
t.Errorf("result mismatch: have %s, want %s", result, false)
}
}

0 comments on commit bd038ef

Please sign in to comment.