core: add maxBlockSystemFee to native Policy

Closes #1195
This commit is contained in:
Anna Shaleva 2020-08-03 16:35:05 +03:00
parent 13336f9dba
commit c647f8e4ed
3 changed files with 124 additions and 1 deletions

View file

@ -113,6 +113,52 @@ func TestFeePerByte(t *testing.T) {
})
}
func TestBlockSystemFee(t *testing.T) {
chain := newTestChain(t)
defer chain.Close()
t.Run("get, internal method", func(t *testing.T) {
n := chain.contracts.Policy.GetMaxBlockSystemFeeInternal(chain.dao)
require.Equal(t, 9000*native.GASFactor, int(n))
})
t.Run("get", func(t *testing.T) {
res, err := invokeNativePolicyMethod(chain, "getMaxBlockSystemFee")
require.NoError(t, err)
checkResult(t, res, smartcontract.Parameter{
Type: smartcontract.IntegerType,
Value: 9000 * native.GASFactor,
})
require.NoError(t, chain.persist())
})
t.Run("set, too low fee", func(t *testing.T) {
res, err := invokeNativePolicyMethod(chain, "setMaxBlockSystemFee", bigint.ToBytes(big.NewInt(4007600)))
require.NoError(t, err)
checkResult(t, res, smartcontract.Parameter{
Type: smartcontract.BoolType,
Value: false,
})
})
t.Run("set, success", func(t *testing.T) {
res, err := invokeNativePolicyMethod(chain, "setMaxBlockSystemFee", bigint.ToBytes(big.NewInt(100000000)))
require.NoError(t, err)
checkResult(t, res, smartcontract.Parameter{
Type: smartcontract.BoolType,
Value: true,
})
require.NoError(t, chain.persist())
res, err = invokeNativePolicyMethod(chain, "getMaxBlockSystemFee")
require.NoError(t, err)
checkResult(t, res, smartcontract.Parameter{
Type: smartcontract.IntegerType,
Value: 100000000,
})
require.NoError(t, chain.persist())
})
}
func TestBlockedAccounts(t *testing.T) {
chain := newTestChain(t)
defer chain.Close()