mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-09 03:13:13 +00:00
Merge pull request #1254 from nspcc-dev/native/policy/maxblocksystemfee
core, consensus: add maxBlockSystemFee to native Policy
This commit is contained in:
commit
62f5aa8eb4
6 changed files with 193 additions and 14 deletions
|
@ -47,7 +47,12 @@ func TestMaxBlockSize(t *testing.T) {
|
|||
chain := newTestChain(t)
|
||||
defer chain.Close()
|
||||
|
||||
t.Run("get", func(t *testing.T) {
|
||||
t.Run("get, internal method", func(t *testing.T) {
|
||||
n := chain.contracts.Policy.GetMaxBlockSizeInternal(chain.dao)
|
||||
require.Equal(t, 1024*256, int(n))
|
||||
})
|
||||
|
||||
t.Run("get, contract method", func(t *testing.T) {
|
||||
res, err := invokeNativePolicyMethod(chain, "getMaxBlockSize")
|
||||
require.NoError(t, err)
|
||||
checkResult(t, res, stackitem.NewBigInteger(big.NewInt(1024*256)))
|
||||
|
@ -92,6 +97,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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue