Skip to content

Commit bd038ef

Browse files
author
Tim Williams
committed
add tests for CheckContractAdminStatus
1 parent eecf40e commit bd038ef

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

node/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func (n *Node) CheckContractAdminStatusWrapper(conn *ethclient.Client) func(addr
309309
}
310310
}
311311

312-
func (n *Node) CheckContractAdminStatus(addr common.Address, conn *ethclient.Client) bool {
312+
func (n *Node) CheckContractAdminStatus(addr common.Address, conn bind.ContractCaller) bool {
313313
signerContract, err := shyft_contracts.NewValidSignersCaller(common.HexToAddress(n.config.WhisperSignersContract), conn)
314314
if err != nil {
315315
log.Info("Signer contract not initialized")

node/node_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ import (
2424
"testing"
2525
"time"
2626

27+
"math/big"
28+
29+
"github.com/ShyftNetwork/go-empyrean/accounts/abi/bind"
30+
"github.com/ShyftNetwork/go-empyrean/accounts/abi/bind/backends"
2731
"github.com/ShyftNetwork/go-empyrean/common"
32+
"github.com/ShyftNetwork/go-empyrean/core"
2833
"github.com/ShyftNetwork/go-empyrean/crypto"
34+
"github.com/ShyftNetwork/go-empyrean/generated_bindings"
2935
"github.com/ShyftNetwork/go-empyrean/p2p"
3036
"github.com/ShyftNetwork/go-empyrean/rpc"
3137
whisper "github.com/ShyftNetwork/go-empyrean/whisper/whisperv6"
@@ -615,3 +621,24 @@ func TestWhisperChannels(t *testing.T) {
615621
t.Errorf("result mismatch: have %s, want %s", resp, testAddrA)
616622
}
617623
}
624+
625+
func TestCheckContractAdminStatus(t *testing.T) {
626+
key0, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
627+
addr0 := crypto.PubkeyToAddress(key0.PublicKey)
628+
deployTransactor := bind.NewKeyedTransactor(key0)
629+
backend := backends.NewSimulatedBackend(core.GenesisAlloc{addr0: {Balance: big.NewInt(1000000000)}}, 10000000)
630+
addr, _, _, err := shyft_contracts.DeployValidSigners(deployTransactor, backend)
631+
if err != nil {
632+
t.Errorf("Deploy Valid Signers Contract failed ", err)
633+
}
634+
t.Log("add is ", addr)
635+
stack, err := New(testNodeConfig())
636+
if err != nil {
637+
t.Fatalf("failed to create protocol stack: %v", err)
638+
}
639+
result := stack.CheckContractAdminStatus(addr0, backend)
640+
641+
if result != false {
642+
t.Errorf("result mismatch: have %s, want %s", result, false)
643+
}
644+
}

0 commit comments

Comments
 (0)