autogenerate testaddrs func created
This commit is contained in:
parent
3bac02b7d0
commit
7b4c632066
|
@ -115,8 +115,8 @@ func TestValidatorBasics(t *testing.T) {
|
|||
|
||||
resVals = keeper.GetValidatorsBonded(ctx)
|
||||
require.Equal(t, 3, len(resVals))
|
||||
assert.True(ValEq(t, validators[0], resVals[2])) // order doesn't matter here
|
||||
assert.True(ValEq(t, validators[1], resVals[0]))
|
||||
assert.True(ValEq(t, validators[0], resVals[0])) // order doesn't matter here
|
||||
assert.True(ValEq(t, validators[1], resVals[2]))
|
||||
assert.True(ValEq(t, validators[2], resVals[1]))
|
||||
|
||||
// remove a record
|
||||
|
|
|
@ -3,6 +3,7 @@ package stake
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -162,3 +163,36 @@ func testAddr(addr string, bech string) sdk.Address {
|
|||
|
||||
return res
|
||||
}
|
||||
|
||||
func createTestAddrs(numAddrs int) []sdk.Address {
|
||||
var addresses []sdk.Address
|
||||
var buffer bytes.Buffer
|
||||
|
||||
//start at 10 to avoid changing 1 to 01, 2 to 02, etc
|
||||
for i := 10; i < numAddrs; i++ {
|
||||
numString := strconv.Itoa(i)
|
||||
buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA61") //base address string
|
||||
|
||||
buffer.WriteString(numString) //adding on final two digits to make addresses unique
|
||||
res, _ := sdk.GetAccAddressHex(buffer.String())
|
||||
bech, _ := sdk.Bech32CosmosifyAcc(res)
|
||||
addresses = append(addresses, testAddr(buffer.String(), bech))
|
||||
buffer.Reset()
|
||||
}
|
||||
return addresses
|
||||
}
|
||||
|
||||
func createTestPubKeys(numPubKeys int) []crypto.PubKey {
|
||||
var publicKeys []crypto.PubKey
|
||||
var buffer bytes.Buffer
|
||||
|
||||
//start at 10 to avoid changing 1 to 01, 2 to 02, etc
|
||||
for i := 10; i < numPubKeys; i++ {
|
||||
numString := strconv.Itoa(i)
|
||||
buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AFB") //base pubkey string
|
||||
buffer.WriteString(numString) //adding on final two digits to make pubkeys unique
|
||||
publicKeys = append(publicKeys, newPubKey(buffer.String()))
|
||||
buffer.Reset()
|
||||
}
|
||||
return publicKeys
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
hrsPerYr = 8766 // as defined by a julian year of 365.25 days
|
||||
precision = 1000000000
|
||||
hrsPerYr = 8766 // as defined by a julian year of 365.25 days
|
||||
precision = 100000000000 // increased to this precision for accuracy with tests on tick_test.go
|
||||
)
|
||||
|
||||
var hrsPerYrRat = sdk.NewRat(hrsPerYr) // as defined by a julian year of 365.25 days
|
||||
|
@ -57,7 +57,7 @@ func (k Keeper) nextInflation(ctx sdk.Context) (inflation sdk.Rat) {
|
|||
params := k.GetParams(ctx)
|
||||
pool := k.GetPool(ctx)
|
||||
// The target annual inflation rate is recalculated for each previsions cycle. The
|
||||
// inflation is also subject to a rate change (positive of negative) depending or
|
||||
// inflation is also subject to a rate change (positive or negative) depending on
|
||||
// the distance from the desired ratio (67%). The maximum rate change possible is
|
||||
// defined to be 13% per year, however the annual inflation is capped as between
|
||||
// 7% and 20%.
|
||||
|
|
|
@ -112,7 +112,7 @@ func TestProcessProvisions(t *testing.T) {
|
|||
// process the provisions a year
|
||||
for hr := 0; hr < 8766; hr++ {
|
||||
pool := keeper.GetPool(ctx)
|
||||
expInflation := keeper.nextInflation(ctx).Round(1000000000)
|
||||
expInflation := keeper.nextInflation(ctx)
|
||||
expProvisions := (expInflation.Mul(sdk.NewRat(pool.TokenSupply())).Quo(hrsPerYrRat)).Evaluate()
|
||||
startBondedTokens := pool.BondedTokens
|
||||
startTotalSupply := pool.TokenSupply()
|
||||
|
|
Loading…
Reference in New Issue