mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-07-01 10:22:30 +00:00

* adjust issuePoPRewards to mint stagedCRDDL * add GetChallengeRange * add resolveStagedClaims on ReissueRDDLResult msg * move claim resolve to distribution result * add StagedDenom and ClaimDenom to config * added the prepare4linting.sh script * renamed PoPEpochs to PopEpochs * renamed DistributionAddressPoP to DistributionAddressPop * added config value ReIssuanceEpochs * detached the re-issuance from the distribution process and schedule them independently * changed logging messages * added an explicit util/kv_serialize.go file to have all KV serialization done * switched to Bigendian serialization of int64 to have the ordered list on the kvstore * added ComputeReIssuanceValue to enable re-issuances once a day or defined by ReIssuanceEpoch * integrated a ReIssuanceValue computation test case * adjusted the challenges test cases to be epoch-dependent * added ReIssuances per ReIssuanceEpoch * extended the Reissue message * checking ReIssuanceProposal in the ante handler * added precision setter for the UINT to RDDL token converter (and test cases) * add e2e test case for pop rewards Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com>
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package util
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gotest.tools/assert"
|
|
)
|
|
|
|
func Test2FloatConvertion(t *testing.T) {
|
|
t.Parallel()
|
|
var expectedValue uint64 = 99869000000
|
|
value := RDDLToken2Uint(998.69)
|
|
assert.Equal(t, expectedValue, value)
|
|
}
|
|
|
|
func Test2UintConvertion(t *testing.T) {
|
|
t.Parallel()
|
|
expectedValue := 998.69
|
|
value := RDDLToken2Float(99869000000)
|
|
assert.Equal(t, expectedValue, value)
|
|
}
|
|
|
|
func TestStringToFloat(t *testing.T) {
|
|
t.Parallel()
|
|
expectedValue := 998.69
|
|
value, err := RDDLTokenStringToFloat("998.69")
|
|
assert.Equal(t, expectedValue, value)
|
|
assert.Equal(t, nil, err)
|
|
}
|
|
|
|
func TestStringToUint(t *testing.T) {
|
|
t.Parallel()
|
|
var expectedValue uint64 = 99869000000
|
|
value, err := RDDLTokenStringToUint("998.69")
|
|
assert.Equal(t, expectedValue, value)
|
|
assert.Equal(t, nil, err)
|
|
}
|
|
|
|
func TestAddPrecisionLongerThan8(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
var input uint64 = 99869000000
|
|
expectedValue := "998.69000000"
|
|
rddlTokenString := UintValueToRDDLTokenString(input)
|
|
assert.Equal(t, expectedValue, rddlTokenString)
|
|
}
|
|
|
|
func TestAddPrecisionEqual8(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
var input uint64 = 69000000
|
|
expectedValue := "0.69000000"
|
|
rddlTokenString := UintValueToRDDLTokenString(input)
|
|
assert.Equal(t, expectedValue, rddlTokenString)
|
|
}
|
|
|
|
func TestAddPrecisionShorterThan8(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
var input uint64 = 9000000
|
|
expectedValue := "0.09000000"
|
|
rddlTokenString := UintValueToRDDLTokenString(input)
|
|
assert.Equal(t, expectedValue, rddlTokenString)
|
|
}
|