aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-12-31 23:28:54 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commitf5a09dcb63dd5d0af3fa6d3d5346223b454ec561 (patch)
tree34ce5405c61dda686dbd8b48b8ad01ca314d3b5c /core
parente741eb75e763e3f037804fe810c5eddd3a1c078d (diff)
downloaddexon-f5a09dcb63dd5d0af3fa6d3d5346223b454ec561.tar.gz
dexon-f5a09dcb63dd5d0af3fa6d3d5346223b454ec561.tar.zst
dexon-f5a09dcb63dd5d0af3fa6d3d5346223b454ec561.zip
core: vm: add missing unittests for nodes/delegators (#116)
Diffstat (limited to 'core')
-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))