diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-04-26 19:05:48 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-15 22:09:56 +0800 |
commit | 2d3b0088eb051aa157046c396024a51cac5d87fc (patch) | |
tree | ead1bc332e2c5dd03f7c3ba738765b15a069575a /core/vm/oracle_contracts_test.go | |
parent | 264000767891fbeb2360e495d195a0820115ad85 (diff) | |
download | go-tangerine-2d3b0088eb051aa157046c396024a51cac5d87fc.tar go-tangerine-2d3b0088eb051aa157046c396024a51cac5d87fc.tar.gz go-tangerine-2d3b0088eb051aa157046c396024a51cac5d87fc.tar.bz2 go-tangerine-2d3b0088eb051aa157046c396024a51cac5d87fc.tar.lz go-tangerine-2d3b0088eb051aa157046c396024a51cac5d87fc.tar.xz go-tangerine-2d3b0088eb051aa157046c396024a51cac5d87fc.tar.zst go-tangerine-2d3b0088eb051aa157046c396024a51cac5d87fc.zip |
core: vm: implement transferNodeOwnershipByFoundation (#399)
Diffstat (limited to 'core/vm/oracle_contracts_test.go')
-rw-r--r-- | core/vm/oracle_contracts_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/core/vm/oracle_contracts_test.go b/core/vm/oracle_contracts_test.go index be1e2a27d..5be893f95 100644 --- a/core/vm/oracle_contracts_test.go +++ b/core/vm/oracle_contracts_test.go @@ -322,6 +322,40 @@ func (g *OracleContractsTestSuite) TestTransferNodeOwnership() { g.Require().Error(err) } +func (g *OracleContractsTestSuite) TestTransferNodeOwnershipByFoundation() { + privKey, addr := newPrefundAccount(g.stateDB) + pk := crypto.FromECDSAPub(&privKey.PublicKey) + + amount := new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e6)) + input, err := GovernanceABI.ABI.Pack("register", pk, "Test1", "test1@dexon.org", "Taipei", "https://dexon.org") + g.Require().NoError(err) + _, err = g.call(GovernanceContractAddress, addr, input, amount) + g.Require().NoError(err) + + _, newAddr := newPrefundAccount(g.stateDB) + + // Call with not valid new owner. + input, err = GovernanceABI.ABI.Pack("transferNodeOwnershipByFoundation", common.Address{}, newAddr) + g.Require().NoError(err) + _, err = g.call(GovernanceContractAddress, addr, input, big.NewInt(0)) + g.Require().NotNil(err) + + input, err = GovernanceABI.ABI.Pack("transferNodeOwnershipByFoundation", addr, newAddr) + g.Require().NoError(err) + + // Call with gov owner. + _, noneOwner := newPrefundAccount(g.stateDB) + _, err = g.call(GovernanceContractAddress, noneOwner, input, big.NewInt(0)) + g.Require().Error(err) + + // Call with gov owner. + _, err = g.call(GovernanceContractAddress, g.config.Owner, input, big.NewInt(0)) + g.Require().NoError(err) + g.Require().Equal(-1, int(g.s.NodesOffsetByAddress(addr).Int64())) + g.Require().Equal(0, int(g.s.NodesOffsetByNodeKeyAddress(addr).Int64())) + g.Require().Equal(0, int(g.s.NodesOffsetByAddress(newAddr).Int64())) +} + func (g *OracleContractsTestSuite) TestReplaceNodePublicKey() { privKey, addr := newPrefundAccount(g.stateDB) pk := crypto.FromECDSAPub(&privKey.PublicKey) |