MCPcopy Create free account
hub / github.com/CPChain/chain / TestRNodeJoinRNode

Function TestRNodeJoinRNode

contracts/dpor/rnode/rnode_test.go:42–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestRNodeJoinRNode(t *testing.T) {
43 // deploy contract
44 contractBackend := backends.NewDporSimulatedBackend(core.GenesisAlloc{
45 ownerAddr: {Balance: big.NewInt(1000000000000)},
46 candidateAddr: {Balance: new(big.Int).Mul(big.NewInt(1000000), big.NewInt(configs.Cpc))},
47 candidate2Addr: {Balance: new(big.Int).Mul(big.NewInt(1000000), big.NewInt(configs.Cpc))}})
48 _, instance := deploy(ownerKey, contractBackend)
49
50 // join rnode
51 candidateTransactOpts := bind.NewKeyedTransactor(candidateKey)
52 candidateInvest := new(big.Int).Mul(big.NewInt(200000), big.NewInt(1e+18))
53 candidateTransactOpts.GasLimit = uint64(50000000)
54 candidateTransactOpts.Value = candidateInvest
55 _, err := instance.JoinRnode(candidateTransactOpts, initVersion)
56 checkError(t, "join rnode", err)
57
58 contractBackend.Commit()
59
60 checkIsRNode(t, instance, candidateAddr, true)
61
62 checkRNodeNum(t, instance, 1)
63}
64
65func TestRNodeNotEnoughInvest(t *testing.T) {
66 // deploy contract

Callers

nothing calls this directly

Calls 6

checkIsRNodeFunction · 0.85
checkRNodeNumFunction · 0.85
deployFunction · 0.70
checkErrorFunction · 0.70
JoinRnodeMethod · 0.65
CommitMethod · 0.65

Tested by

no test coverage detected