(t *testing.T)
| 315 | } |
| 316 | |
| 317 | func TestRNodeWithSupportedVersion(t *testing.T) { |
| 318 | // deploy contract |
| 319 | contractBackend := backends.NewDporSimulatedBackend(core.GenesisAlloc{ |
| 320 | ownerAddr: {Balance: big.NewInt(1000000000000)}, |
| 321 | candidateAddr: {Balance: new(big.Int).Mul(big.NewInt(1000000), big.NewInt(configs.Cpc))}, |
| 322 | candidate2Addr: {Balance: new(big.Int).Mul(big.NewInt(1000000), big.NewInt(configs.Cpc))}}) |
| 323 | _, instance := deploy(ownerKey, contractBackend) |
| 324 | |
| 325 | // join rnode |
| 326 | candidateTransactOpts := bind.NewKeyedTransactor(candidateKey) |
| 327 | candidateInvest := new(big.Int).Mul(big.NewInt(200000), big.NewInt(1e+18)) |
| 328 | candidateTransactOpts.GasLimit = uint64(50000000) |
| 329 | candidateTransactOpts.Value = candidateInvest |
| 330 | _, err := instance.JoinRnode(candidateTransactOpts, initVersion) |
| 331 | checkError(t, "join rnode", err) |
| 332 | |
| 333 | contractBackend.Commit() |
| 334 | |
| 335 | checkIsRNode(t, instance, candidateAddr, true) |
| 336 | |
| 337 | checkRNodeNum(t, instance, 1) |
| 338 | |
| 339 | // set supportedVersion to 2 |
| 340 | ownerTransactOpts := bind.NewKeyedTransactor(ownerKey) |
| 341 | ownerInvest := new(big.Int).Mul(big.NewInt(0), big.NewInt(1e+18)) |
| 342 | ownerTransactOpts.GasLimit = uint64(50000000) |
| 343 | ownerTransactOpts.Value = ownerInvest |
| 344 | |
| 345 | secondVersion := big.NewInt(2) |
| 346 | _, err = instance.SetSupportedVersion(ownerTransactOpts, secondVersion) |
| 347 | checkError(t, "set supported version", err) |
| 348 | |
| 349 | contractBackend.Commit() |
| 350 | |
| 351 | // join rnode with initVersion |
| 352 | candidate2TransactOpts := bind.NewKeyedTransactor(candidate2Key) |
| 353 | candidate2Invest := new(big.Int).Mul(big.NewInt(200000), big.NewInt(1e+18)) |
| 354 | candidate2TransactOpts.GasLimit = uint64(50000000) |
| 355 | candidate2TransactOpts.Value = candidate2Invest |
| 356 | _, err = instance.JoinRnode(candidate2TransactOpts, initVersion) |
| 357 | checkError(t, "join rnode with init version", err) |
| 358 | |
| 359 | contractBackend.Commit() |
| 360 | |
| 361 | checkIsRNode(t, instance, candidate2Addr, false) |
| 362 | |
| 363 | checkRNodeNum(t, instance, 1) |
| 364 | |
| 365 | // join rnode with secondVersion |
| 366 | _, err = instance.JoinRnode(candidate2TransactOpts, secondVersion) |
| 367 | checkError(t, "join rnode with second version", err) |
| 368 | |
| 369 | contractBackend.Commit() |
| 370 | |
| 371 | checkIsRNode(t, instance, candidate2Addr, true) |
| 372 | |
| 373 | checkRNodeNum(t, instance, 2) |
| 374 | } |
nothing calls this directly
no test coverage detected