aboutsummaryrefslogtreecommitdiffstats
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-04-09 21:32:55 +0800
commitb0a5c54715472109072d486f1f95c578efbd3038 (patch)
treea9a5a0330ba2a21a1195cb374cb98471a8687309
parentfdf77b0b11e472b590368e9908cbdd08bd09a249 (diff)
downloaddexon-b0a5c54715472109072d486f1f95c578efbd3038.tar
dexon-b0a5c54715472109072d486f1f95c578efbd3038.tar.gz
dexon-b0a5c54715472109072d486f1f95c578efbd3038.tar.bz2
dexon-b0a5c54715472109072d486f1f95c578efbd3038.tar.lz
dexon-b0a5c54715472109072d486f1f95c578efbd3038.tar.xz
dexon-b0a5c54715472109072d486f1f95c578efbd3038.tar.zst
dexon-b0a5c54715472109072d486f1f95c578efbd3038.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))