Skip to content

Commit

Permalink
Merge pull request #413 from GrKamil/dev
Browse files Browse the repository at this point in the history
fix min validator stake
  • Loading branch information
danil-lashin authored Sep 29, 2020
2 parents 6704512 + 04bd73e commit a087d68
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions core/state/candidates/candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,8 +1006,8 @@ func TestCandidates_GetNewCandidates(t *testing.T) {
{
Owner: [20]byte{1},
Coin: 0,
Value: "1000000000000000",
BipValue: "1000000000000000",
Value: "1000000000000000000000",
BipValue: "1000000000000000000000",
},
}, nil)
candidates.SetOnline([32]byte{4})
Expand All @@ -1017,8 +1017,8 @@ func TestCandidates_GetNewCandidates(t *testing.T) {
{
Owner: [20]byte{1},
Coin: 0,
Value: "1000000000000000",
BipValue: "1000000000000000",
Value: "1000000000000000000000",
BipValue: "1000000000000000000000",
},
}, nil)
candidates.SetOnline([32]byte{5})
Expand Down
2 changes: 1 addition & 1 deletion core/state/candidates/candidates.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
)

var (
minValidatorBipStake = big.NewInt(1000)
minValidatorBipStake = helpers.BipToPip(big.NewInt(1000))
)

// RCandidates interface represents Candidates state
Expand Down
2 changes: 1 addition & 1 deletion core/state/candidates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func TestDoubleAbsentPenalty(t *testing.T) {
pubkey := createTestCandidate(st)

coin := types.GetBaseCoinID()
amount := big.NewInt(1000)
amount := helpers.BipToPip(big.NewInt(1000))
var addr types.Address
binary.BigEndian.PutUint64(addr[:], 1)
st.Candidates.Delegate(addr, pubkey, coin, amount, big.NewInt(0))
Expand Down
19 changes: 10 additions & 9 deletions core/state/validators/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/MinterTeam/minter-go-node/core/state/candidates"
"github.com/MinterTeam/minter-go-node/core/state/checker"
"github.com/MinterTeam/minter-go-node/core/types"
"github.com/MinterTeam/minter-go-node/helpers"
"github.com/MinterTeam/minter-go-node/tree"
db "github.com/tendermint/tm-db"
"math/big"
Expand Down Expand Up @@ -244,8 +245,8 @@ func TestValidators_PayRewards(t *testing.T) {
{
Owner: [20]byte{1},
Coin: 0,
Value: "10000",
BipValue: "10000",
Value: "1000000000000000000000",
BipValue: "1000000000000000000000",
},
}, nil)
candidatesS.RecalculateStakes(0)
Expand Down Expand Up @@ -308,8 +309,8 @@ func TestValidators_SetValidatorAbsent(t *testing.T) {
{
Owner: [20]byte{1},
Coin: 0,
Value: "10000",
BipValue: "10000",
Value: "1000000000000000000000",
BipValue: "1000000000000000000000",
},
}, nil)
candidatesS.RecalculateStakes(0)
Expand Down Expand Up @@ -402,7 +403,7 @@ func TestValidators_Export(t *testing.T) {
newValidator := NewValidator(
[32]byte{4},
types.NewBitArray(ValidatorMaxAbsentWindow),
big.NewInt(1000000),
helpers.BipToPip(big.NewInt(1000000)),
big.NewInt(100),
true,
true,
Expand All @@ -420,8 +421,8 @@ func TestValidators_Export(t *testing.T) {
{
Owner: [20]byte{1},
Coin: 0,
Value: "10000",
BipValue: "10000",
Value: "1000000000000000000000",
BipValue: "1000000000000000000000",
},
}, nil)
candidatesS.RecalculateStakes(0)
Expand All @@ -440,7 +441,7 @@ func TestValidators_Export(t *testing.T) {
t.Fatalf("version %d", version)
}

if fmt.Sprintf("%X", hash) != "9387AD1250A4943193BCB44AFF1F4EBFEC626B53FD5A980181AFD7E03079862E" {
if fmt.Sprintf("%X", hash) != "1D50F5F03FAB5D800DBF8D9254DDC68AEAC589BD30F2839A3A5B68887CE0E34C" {
t.Fatalf("hash %X", hash)
}

Expand All @@ -452,7 +453,7 @@ func TestValidators_Export(t *testing.T) {
t.Fatal(err)
}

if string(bytes) != "[{\"total_bip_stake\":\"10000\",\"public_key\":\"Mp0400000000000000000000000000000000000000000000000000000000000000\",\"accum_reward\":\"100\",\"absent_times\":\"________________________\"}]" {
if string(bytes) != "[{\"total_bip_stake\":\"1000000000000000000000\",\"public_key\":\"Mp0400000000000000000000000000000000000000000000000000000000000000\",\"accum_reward\":\"100\",\"absent_times\":\"________________________\"}]" {
t.Log(string(bytes))
t.Fatal("not equal JSON")
}
Expand Down

0 comments on commit a087d68

Please sign in to comment.