Skip to content

Commit

Permalink
Delete unused parameter for 'testEnv.withComplexityLimit'.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickeskov committed Jul 27, 2024
1 parent 6bedc9d commit fffc625
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 115 deletions.
18 changes: 9 additions & 9 deletions pkg/ride/complexity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ func checkVerifierSpentComplexity(t *testing.T, env environment, code string, co
}

func checkVerifierSpentComplexityV5(t *testing.T, code string, complexity int, comment string) {
env := newTestEnv(t).withLibVersion(ast.LibV5).withComplexityLimit(ast.LibV5, 2000).toEnv()
env := newTestEnv(t).withLibVersion(ast.LibV5).withComplexityLimit(2000).toEnv()
checkVerifierSpentComplexity(t, env, code, complexity, comment)
}

func checkVerifierSpentComplexityV6(t *testing.T, code string, complexity int, comment string) {
env := newTestEnv(t).withLibVersion(ast.LibV6).withComplexityLimit(ast.LibV6, 2000).withRideV6Activated().toEnv()
env := newTestEnv(t).withLibVersion(ast.LibV6).withComplexityLimit(2000).withRideV6Activated().toEnv()
checkVerifierSpentComplexity(t, env, code, complexity, comment)
}

Expand All @@ -38,12 +38,12 @@ func checkFunctionCallComplexity(t *testing.T, env environment, code, fn string,
}

func checkFunctionCallComplexityV5(t *testing.T, code, fn string, fa proto.Arguments, complexity int) {
env := newTestEnv(t).withLibVersion(ast.LibV5).withComplexityLimit(ast.LibV5, 2000).toEnv()
env := newTestEnv(t).withLibVersion(ast.LibV5).withComplexityLimit(2000).toEnv()
checkFunctionCallComplexity(t, env, code, fn, fa, complexity)
}

func checkFunctionCallComplexityV6(t *testing.T, code, fn string, fa proto.Arguments, complexity int) {
env := newTestEnv(t).withLibVersion(ast.LibV6).withComplexityLimit(ast.LibV6, 2000).withRideV6Activated().toEnv()
env := newTestEnv(t).withLibVersion(ast.LibV6).withComplexityLimit(2000).withRideV6Activated().toEnv()
checkFunctionCallComplexity(t, env, code, fn, fa, complexity)
}

Expand Down Expand Up @@ -71,7 +71,7 @@ func TestSimpleScriptsComplexity(t *testing.T) {
} {
_, tree := parseBase64Script(t, test.source)

env := newTestEnv(t).withLibVersion(ast.LibV4).withComplexityLimit(ast.LibV4, 2000).
env := newTestEnv(t).withLibVersion(ast.LibV4).withComplexityLimit(2000).
withTransaction(testTransferWithProofs(t)).toEnv()
res, err := CallVerifier(env, tree)
require.NoError(t, err, test.comment)
Expand Down Expand Up @@ -238,7 +238,7 @@ func TestStrictThrow(t *testing.T) {
*/
code := "BAoBAAAACHRlc3RGdW5jAAAAAAQAAAABYQkAAAIAAAABAgAAABVTdHJpY3QgZXhlY3V0ZWQgZXJyb3IDCQAAAAAAAAIFAAAAAWEFAAAAAWEGCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkBAAAACHRlc3RGdW5jAAAAABn7LqM="
_, tree := parseBase64Script(t, code)
_, err := CallVerifier(newTestEnv(t).withComplexityLimit(ast.LibV5, 2000).toEnv(), tree)
_, err := CallVerifier(newTestEnv(t).withComplexityLimit(2000).toEnv(), tree)
require.Errorf(t, err, "Strict executed error")
}

Expand Down Expand Up @@ -339,7 +339,7 @@ func TestOnEdgeComplexity1(t *testing.T) {
dApp := newTestAccount(t, "DAPP1") // 3MzDtgL5yw73C2xVLnLJCrT5gCL4357a4sz
_, tree := parseBase64Script(t, "BgIHCAISAwoBAQABA2ludgEDZm9vAQFuBAtjb21wbGV4SW50MQkAZAIJAGQCCQBkAgkAZAIJAGQCCQBkAgkAZAIJAGQCCQBkAgkAZAIJAGQCCQBkAgkAZAIJAGQCCQBkAgkAZAIJAGQCCQBkAgABCQCgAwEJAHcGCQCnAwECBDE2MjUAAgkApwMBAgIyNwABAAIFBkhBTEZVUAkAoAMBCQB3BgkApwMBAgQxNjI1AAIJAKcDAQICMjcAAQACBQZIQUxGVVAJAG0GANkMAAIAGwABAAIFBkhBTEZVUAkAbQYA2QwAAgAbAAEAAgUGSEFMRlVQCQELdmFsdWVPckVsc2UCCQCfCAECAWsAAAkBC3ZhbHVlT3JFbHNlAgkAnwgBAgFrAAAJAQt2YWx1ZU9yRWxzZQIJAJ8IAQIBawAAAAEAAQABAAEAAQABAAEAAQABAAEAAQQLY29tcGxleEludDIDCQBmAgUBbgABCQELdmFsdWVPckVsc2UCCgABQAkA/AcECQEHQWRkcmVzcwEBGgFUcQ97e0JWLZUBUuI05V2T+HgxB8fHAvABAgNmb28JAMwIAgkAZQIFAW4AAQUDbmlsBQNuaWwDCQABAgUBQAIDSW50BQFABQR1bml0AAAJAGQCCQBkAgkAZAIJAGQCCQBkAgkAZAIJAGQCCQBkAgkAZAIJAGQCAAEJAQt2YWx1ZU9yRWxzZQIJAJ8IAQIBawAACQELdmFsdWVPckVsc2UCCQCfCAECAWsAAAkBC3ZhbHVlT3JFbHNlAgkAnwgBAgFrAAAJAQt2YWx1ZU9yRWxzZQIJAJ8IAQIBawAACQELdmFsdWVPckVsc2UCCQCfCAECAWsAAAkBC3ZhbHVlT3JFbHNlAgkAnwgBAgFrAAAAAQABAAEAAQkAlAoCBQNuaWwJAGQCBQtjb21wbGV4SW50MQULY29tcGxleEludDIApaxBJw==")

env := newTestEnv(t).withLibVersion(ast.LibV6).withComplexityLimit(ast.LibV6, 52000).
env := newTestEnv(t).withLibVersion(ast.LibV6).withComplexityLimit(52000).
withBlockV5Activated().withProtobufTx().withDataEntriesSizeV2().
withRideV6Activated().withValidateInternalPayments().withThis(dApp).withDApp(dApp).withSender(dApp).
withInvocation("foo").withDataEntries(dApp, &proto.IntegerDataEntry{Key: "k", Value: 1}).
Expand Down Expand Up @@ -374,7 +374,7 @@ func TestOnEdgeComplexity2(t *testing.T) {
*/
dApp := newTestAccount(t, "DAPP1") // 3MzDtgL5yw73C2xVLnLJCrT5gCL4357a4sz
_, tree := parseBase64Script(t, "BgIHCAISAwoBAQABA2ludgEDZm9vAQFuBAZyZXN1bHQDCQBmAgUBbgABBAtjb21wbGV4SW50MQkAZAIJAGQCCQBkAgkAZAIJAGQCCQBkAgkAZAIJAGQCCQBkAgABCQCgAwEJAHcGCQCnAwECBDE2MjUAAgkApwMBAgIyNwABAAIFBkhBTEZVUAkAoAMBCQB3BgkApwMBAgQxNjI1AAIJAKcDAQICMjcAAQACBQZIQUxGVVAJAG0GANkMAAIAGwABAAIFBkhBTEZVUAkAbQYA2QwAAgAbAAEAAgUGSEFMRlVQCQELdmFsdWVPckVsc2UCCQCfCAECAWsAAAkBC3ZhbHVlT3JFbHNlAgkAnwgBAgFrAAAJAQt2YWx1ZU9yRWxzZQIJAJ8IAQIBawAACQELdmFsdWVPckVsc2UCCQCfCAECAWsAAAABAwkAZgIFC2NvbXBsZXhJbnQxAAAJAPwHBAkBB0FkZHJlc3MBARoBVHEPe3tCVi2VAVLiNOVdk/h4MQfHxwLwAQIDZm9vCQDMCAIJAGUCBQFuAAEFA25pbAUDbmlsAAAJAGQCCQBkAgkAZAIJAGQCCQBkAgkAZAIAAQkAoAMBCQB3BgkApwMBAgQxNjI1AAIJAKcDAQICMjcAAQACBQZIQUxGVVAJAKADAQkAdwYJAKcDAQIEMTYyNQACCQCnAwECAjI3AAEAAgUGSEFMRlVQCQCgAwEJAHcGCQCnAwECBDE2MjUAAgkApwMBAgIyNwABAAIFBkhBTEZVUAABAAEAAQkAlAoCBQNuaWwFBnJlc3VsdADR0fAN")
env := newTestEnv(t).withLibVersion(ast.LibV6).withComplexityLimit(ast.LibV6, 52000).
env := newTestEnv(t).withLibVersion(ast.LibV6).withComplexityLimit(52000).
withBlockV5Activated().withProtobufTx().withDataEntriesSizeV2().
withRideV6Activated().withValidateInternalPayments().withThis(dApp).withDApp(dApp).withSender(dApp).
withInvocation("foo").withDataEntries(dApp, &proto.IntegerDataEntry{Key: "k", Value: 1}).
Expand Down Expand Up @@ -563,7 +563,7 @@ func TestComplexityOverflow(t *testing.T) {
*/
_, tree2 := parseBase64Script(t, "AAIFAAAAAAAAAAQIAhIAAAAABAAAAAADbXNnAQAAAHcTUhKp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ibV5).withComplexityLimit(ast.LibV5, 26000).
env := newTestEnv(t).withLibVersion(ast.LibV5).withComplexityLimit(26000).
withBlockV5Activated().withProtobufTx().
withDataEntriesSizeV2().withMessageLengthV3().
withValidateInternalPayments().withThis(dApp1).
Expand Down
4 changes: 2 additions & 2 deletions pkg/ride/fold_evaluation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/wavesplatform/gowaves/pkg/ride/ast"

"github.com/wavesplatform/gowaves/pkg/ride/serialization"
)

Expand All @@ -18,7 +18,7 @@ func evaluateFold(t *testing.T, code string) {
require.NoError(t, err)
assert.NotNil(t, tree)

env := newTestEnv(t).withComplexityLimit(ast.LibV5, 26000).toEnv()
env := newTestEnv(t).withComplexityLimit(26000).toEnv()
_, err = CallVerifier(env, tree)
require.Error(t, err)
foldId := "450"
Expand Down
2 changes: 1 addition & 1 deletion pkg/ride/functions_proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ func TestTransferByID(t *testing.T) {

for i, testCase := range testCases {
t.Run(strconv.Itoa(i+1), func(t *testing.T) {
env := newTestEnv(t).withLibVersion(ast.LibV5).withComplexityLimit(ast.LibV5, 26000).
env := newTestEnv(t).withLibVersion(ast.LibV5).withComplexityLimit(26000).
withBlockV5Activated().withProtobufTx().
withDataEntriesSizeV2().withMessageLengthV3().
withValidateInternalPayments().withThis(dApp1).
Expand Down
3 changes: 2 additions & 1 deletion pkg/ride/ride_constructors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/stretchr/testify/require"

"github.com/wavesplatform/gowaves/pkg/proto"
"github.com/wavesplatform/gowaves/pkg/ride/ast"
)
Expand Down Expand Up @@ -51,7 +52,7 @@ func TestConstructorsDifferentVersions(t *testing.T) {
check := func(src string, dataEntry proto.DataEntry) {
_, tree := parseBase64Script(t, src)

env := newTestEnv(t).withLibVersion(ast.LibV6).withComplexityLimit(ast.LibV6, 52000).withRideV6Activated().
env := newTestEnv(t).withLibVersion(ast.LibV6).withComplexityLimit(52000).withRideV6Activated().
withSender(sender).withThis(dApp1).withDApp(dApp1).withTree(dApp1, tree).
withInvocation("test")

Expand Down
2 changes: 1 addition & 1 deletion pkg/ride/test_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ func (e *testEnv) withLibVersion(v ast.LibraryVersion) *testEnv {
return e
}

func (e *testEnv) withComplexityLimit(v ast.LibraryVersion, limit int) *testEnv {
func (e *testEnv) withComplexityLimit(limit int) *testEnv {
require.True(e.t, limit >= 0)
var cc complexityCalculator
e.me.complexityCalculatorFunc = func() complexityCalculator {
Expand Down
Loading

0 comments on commit fffc625

Please sign in to comment.