aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-12-31 23:28:54 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:20 +0800
commit12876a86ac3dadd89831c2b02bf9be6fced9e24b (patch)
tree2c2468968973ffb0098e2b8f617ec79d22c42be4
parent59e8802f35e6ccdc23c8cfce548eb6c81dd0dc55 (diff)
downloadgo-tangerine-12876a86ac3dadd89831c2b02bf9be6fced9e24b.tar
go-tangerine-12876a86ac3dadd89831c2b02bf9be6fced9e24b.tar.gz
go-tangerine-12876a86ac3dadd89831c2b02bf9be6fced9e24b.tar.bz2
go-tangerine-12876a86ac3dadd89831c2b02bf9be6fced9e24b.tar.lz
go-tangerine-12876a86ac3dadd89831c2b02bf9be6fced9e24b.tar.xz
go-tangerine-12876a86ac3dadd89831c2b02bf9be6fced9e24b.tar.zst
go-tangerine-12876a86ac3dadd89831c2b02bf9be6fced9e24b.zip
core: vm: add missing unittests for nodes/delegators (#116)
-rw-r--r--core/vm/governance.go4
-rw-r--r--core/vm/governance_test.go12
2 files changed, 13 insertions, 3 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go
index a58985766..6dccc8c7d 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -1133,7 +1133,7 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) (ret []by
return nil, errExecutionReverted
}
delegator := g.state.Delegator(nodeAddr, index)
- res, err := method.Outputs.Pack(delegator.Owner, delegator.Value)
+ res, err := method.Outputs.Pack(delegator.Owner, delegator.Value, delegator.UndelegatedAt)
if err != nil {
return nil, errExecutionReverted
}
@@ -1283,7 +1283,7 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) (ret []by
}
info := g.state.Node(index)
res, err := method.Outputs.Pack(
- info.Owner, info.PublicKey, info.Staked,
+ info.Owner, info.PublicKey, info.Staked, info.Fined,
info.Name, info.Email, info.Location, info.Url, info.Unstaked)
if err != nil {
return nil, errExecutionReverted
diff --git a/core/vm/governance_test.go b/core/vm/governance_test.go
index ee9ae751f..a91aba7b6 100644
--- a/core/vm/governance_test.go
+++ b/core/vm/governance_test.go
@@ -755,10 +755,15 @@ func (g *GovernanceContractTestSuite) TestMiscVariableReading() {
_, err = g.call(addrDelegator2, input, amount)
g.Require().NoError(err)
- input, err = abiObject.Pack("nodesLength")
+ input, err = abiObject.Pack("nodes", big.NewInt(0))
g.Require().NoError(err)
res, err := g.call(addr, input, big.NewInt(0))
g.Require().NoError(err)
+
+ input, err = abiObject.Pack("nodesLength")
+ g.Require().NoError(err)
+ res, err = g.call(addr, input, big.NewInt(0))
+ g.Require().NoError(err)
var value *big.Int
err = abiObject.Unpack(&value, "nodesLength", res)
g.Require().NoError(err)
@@ -772,6 +777,11 @@ func (g *GovernanceContractTestSuite) TestMiscVariableReading() {
g.Require().NoError(err)
g.Require().Equal(0, int(value.Uint64()))
+ input, err = abiObject.Pack("delegators", addr, big.NewInt(0))
+ g.Require().NoError(err)
+ res, err = g.call(addr, input, big.NewInt(0))
+ g.Require().NoError(err)
+
input, err = abiObject.Pack("delegatorsLength", addr)
g.Require().NoError(err)
res, err = g.call(addr, input, big.NewInt(0))