core: use big.Int to store NEP5 balances

closes #1133
This commit is contained in:
Anna Shaleva 2020-07-09 12:57:24 +03:00
parent 43b28ffa06
commit abe3c94b95
15 changed files with 93 additions and 72 deletions

View file

@ -1,6 +1,7 @@
package core
import (
"math/big"
"testing"
"time"
@ -196,23 +197,23 @@ func TestGetClaimable(t *testing.T) {
require.NoError(t, err)
t.Run("first generation period", func(t *testing.T) {
amount := bc.CalculateClaimable(1, 0, 2)
require.EqualValues(t, 8, amount)
amount := bc.CalculateClaimable(big.NewInt(1), 0, 2)
require.EqualValues(t, big.NewInt(8), amount)
})
t.Run("a number of full periods", func(t *testing.T) {
amount := bc.CalculateClaimable(1, 0, 6)
require.EqualValues(t, 4+4+3+3+2+2, amount)
amount := bc.CalculateClaimable(big.NewInt(1), 0, 6)
require.EqualValues(t, big.NewInt(4+4+3+3+2+2), amount)
})
t.Run("start from the 2-nd block", func(t *testing.T) {
amount := bc.CalculateClaimable(1, 1, 7)
require.EqualValues(t, 4+3+3+2+2+1, amount)
amount := bc.CalculateClaimable(big.NewInt(1), 1, 7)
require.EqualValues(t, big.NewInt(4+3+3+2+2+1), amount)
})
t.Run("end height after generation has ended", func(t *testing.T) {
amount := bc.CalculateClaimable(1, 1, 10)
require.EqualValues(t, 4+3+3+2+2+1+1, amount)
amount := bc.CalculateClaimable(big.NewInt(1), 1, 10)
require.EqualValues(t, big.NewInt(4+3+3+2+2+1+1), amount)
})
}