aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/oracle_contracts_test.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-29 14:28:04 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-15 22:09:55 +0800
commit038552acaa883a6353c54274f80cb888fb23be68 (patch)
treef658e21cb1345fe8cad1e4402fa346009405fe31 /core/vm/oracle_contracts_test.go
parenta2403c5a125e4939a16e11ba10fadfabe6bbd136 (diff)
downloadgo-tangerine-038552acaa883a6353c54274f80cb888fb23be68.tar
go-tangerine-038552acaa883a6353c54274f80cb888fb23be68.tar.gz
go-tangerine-038552acaa883a6353c54274f80cb888fb23be68.tar.bz2
go-tangerine-038552acaa883a6353c54274f80cb888fb23be68.tar.lz
go-tangerine-038552acaa883a6353c54274f80cb888fb23be68.tar.xz
go-tangerine-038552acaa883a6353c54274f80cb888fb23be68.tar.zst
go-tangerine-038552acaa883a6353c54274f80cb888fb23be68.zip
core: vm: make fail stop fine value configurable (#312)
A node is now quailified only if it has no pending fine and staked >= minstake.
Diffstat (limited to 'core/vm/oracle_contracts_test.go')
-rw-r--r--core/vm/oracle_contracts_test.go29
1 files changed, 13 insertions, 16 deletions
diff --git a/core/vm/oracle_contracts_test.go b/core/vm/oracle_contracts_test.go
index 98cc01505..6a3534ce5 100644
--- a/core/vm/oracle_contracts_test.go
+++ b/core/vm/oracle_contracts_test.go
@@ -89,6 +89,7 @@ func (g *GovernanceStateTestSuite) SetupTest() {
config := params.TestnetChainConfig.Dexcon
g.s.Initialize(config, new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e7)))
+ statedb.AddBalance(GovernanceContractAddress, big.NewInt(1))
statedb.Commit(true)
}
@@ -117,8 +118,9 @@ func (g *GovernanceStateTestSuite) TestReadWriteEraseBytes() {
}
func (g *GovernanceStateTestSuite) TestReadWriteErase1DArray() {
+ emptyOffset := 100
for j := 0; j < 50; j++ {
- idx := big.NewInt(int64(j))
+ idx := big.NewInt(int64(j + emptyOffset))
data := make([][]byte, 30)
for key := range data {
data[key] = randomBytes(3, 32)
@@ -147,12 +149,7 @@ func (g *GovernanceStateTestSuite) TestDisqualify() {
// Disqualify
g.s.Disqualify(node)
node = g.s.Node(big.NewInt(0))
- g.Require().Equal(uint64(1), node.Fined.Uint64())
-
- // Disqualify again should change nothing.
- g.s.Disqualify(node)
- node = g.s.Node(big.NewInt(0))
- g.Require().Equal(uint64(1), node.Fined.Uint64())
+ g.Require().Equal(uint64(0xd78ebc5ac6200000), node.Fined.Uint64())
// Disqualify none exist node should return error.
privKey2, _ := newPrefundAccount(g.stateDB)
@@ -548,7 +545,7 @@ func (g *OracleContractsTestSuite) TestUpdateConfiguration() {
big.NewInt(264*decimalMultiplier),
big.NewInt(600),
big.NewInt(900),
- []*big.Int{big.NewInt(1), big.NewInt(1), big.NewInt(1)})
+ []*big.Int{big.NewInt(1), big.NewInt(1), big.NewInt(1), big.NewInt(1), big.NewInt(1)})
g.Require().NoError(err)
// Call with non-owner.
@@ -716,21 +713,21 @@ func (g *OracleContractsTestSuite) TestReportForkVote() {
g.Require().NoError(err)
// Report wrong type (fork block)
- input, err = GovernanceABI.ABI.Pack("report", big.NewInt(2), vote1Bytes, vote2Bytes)
+ input, err = GovernanceABI.ABI.Pack("report", big.NewInt(FineTypeForkBlock), vote1Bytes, vote2Bytes)
g.Require().NoError(err)
_, err = g.call(GovernanceContractAddress, addr, input, big.NewInt(0))
g.Require().Error(err)
- input, err = GovernanceABI.ABI.Pack("report", big.NewInt(1), vote1Bytes, vote2Bytes)
+ input, err = GovernanceABI.ABI.Pack("report", big.NewInt(FineTypeForkVote), vote1Bytes, vote2Bytes)
g.Require().NoError(err)
_, err = g.call(GovernanceContractAddress, addr, input, big.NewInt(0))
g.Require().NoError(err)
node := g.s.Node(big.NewInt(0))
- g.Require().Equal(node.Fined, g.s.FineValue(big.NewInt(1)))
+ g.Require().Equal(node.Fined, g.s.FineValue(big.NewInt(FineTypeForkVote)))
// Duplicate report should fail.
- input, err = GovernanceABI.ABI.Pack("report", big.NewInt(1), vote1Bytes, vote2Bytes)
+ input, err = GovernanceABI.ABI.Pack("report", big.NewInt(FineTypeForkVote), vote1Bytes, vote2Bytes)
g.Require().NoError(err)
_, err = g.call(GovernanceContractAddress, addr, input, big.NewInt(0))
g.Require().Error(err)
@@ -793,21 +790,21 @@ func (g *OracleContractsTestSuite) TestReportForkBlock() {
g.Require().NoError(err)
// Report wrong type (fork vote)
- input, err = GovernanceABI.ABI.Pack("report", big.NewInt(1), block1Bytes, block2Bytes)
+ input, err = GovernanceABI.ABI.Pack("report", big.NewInt(FineTypeForkVote), block1Bytes, block2Bytes)
g.Require().NoError(err)
_, err = g.call(GovernanceContractAddress, addr, input, big.NewInt(0))
g.Require().Error(err)
- input, err = GovernanceABI.ABI.Pack("report", big.NewInt(2), block1Bytes, block2Bytes)
+ input, err = GovernanceABI.ABI.Pack("report", big.NewInt(FineTypeForkBlock), block1Bytes, block2Bytes)
g.Require().NoError(err)
_, err = g.call(GovernanceContractAddress, addr, input, big.NewInt(0))
g.Require().NoError(err)
node := g.s.Node(big.NewInt(0))
- g.Require().Equal(node.Fined, g.s.FineValue(big.NewInt(2)))
+ g.Require().Equal(node.Fined, g.s.FineValue(big.NewInt(FineTypeForkBlock)))
// Duplicate report should fail.
- input, err = GovernanceABI.ABI.Pack("report", big.NewInt(2), block1Bytes, block2Bytes)
+ input, err = GovernanceABI.ABI.Pack("report", big.NewInt(FineTypeForkBlock), block1Bytes, block2Bytes)
g.Require().NoError(err)
_, err = g.call(GovernanceContractAddress, addr, input, big.NewInt(0))
g.Require().Error(err)