(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func TestRNodeMultiRNodes(t *testing.T) { |
| 120 | // deploy contract |
| 121 | contractBackend := backends.NewDporSimulatedBackend(core.GenesisAlloc{ |
| 122 | ownerAddr: {Balance: big.NewInt(1000000000000)}, |
| 123 | candidateAddr: {Balance: new(big.Int).Mul(big.NewInt(1000000), big.NewInt(configs.Cpc))}, |
| 124 | candidate2Addr: {Balance: new(big.Int).Mul(big.NewInt(1000000), big.NewInt(configs.Cpc))}}) |
| 125 | _, instance := deploy(ownerKey, contractBackend) |
| 126 | |
| 127 | // join rnode |
| 128 | candidateTransactOpts := bind.NewKeyedTransactor(candidateKey) |
| 129 | candidateInvest := new(big.Int).Mul(big.NewInt(200000), big.NewInt(1e+18)) |
| 130 | candidateTransactOpts.GasLimit = uint64(50000000) |
| 131 | candidateTransactOpts.Value = candidateInvest |
| 132 | _, err := instance.JoinRnode(candidateTransactOpts, initVersion) |
| 133 | checkError(t, "join rnode", err) |
| 134 | |
| 135 | contractBackend.Commit() |
| 136 | |
| 137 | checkIsRNode(t, instance, candidateAddr, true) |
| 138 | |
| 139 | checkRNodeNum(t, instance, 1) |
| 140 | |
| 141 | candidate2TransactOpts := bind.NewKeyedTransactor(candidate2Key) |
| 142 | candidate2Invest := new(big.Int).Mul(big.NewInt(200000), big.NewInt(1e+18)) |
| 143 | candidate2TransactOpts.GasLimit = uint64(50000000) |
| 144 | candidate2TransactOpts.Value = candidate2Invest |
| 145 | _, err = instance.JoinRnode(candidate2TransactOpts, initVersion) |
| 146 | checkError(t, "join rnode", err) |
| 147 | |
| 148 | contractBackend.Commit() |
| 149 | |
| 150 | checkIsRNode(t, instance, candidate2Addr, true) |
| 151 | |
| 152 | checkRNodeNum(t, instance, 2) |
| 153 | |
| 154 | // get all rnodes |
| 155 | addrs, err := instance.GetRnodes(nil) |
| 156 | checkError(t, "get all rnodes", err) |
| 157 | if addrs[0] != candidateAddr { |
| 158 | t.Error("rnode 1 is not candidate 1") |
| 159 | } |
| 160 | if addrs[1] != candidate2Addr { |
| 161 | t.Error("rnode 2 is not candidate 2") |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | func TestJoinRNodeAndQuitRNode(t *testing.T) { |
| 166 | // deploy contract |
nothing calls this directly
no test coverage detected