@@ -3009,8 +3009,7 @@ func TestInterpretComputationMeteringRLP(t *testing.T) {
30093009
30103010 storage := NewUnmeteredInMemoryStorage ()
30113011
3012- // TODO: Also run with compiler
3013- inter , err := parseCheckAndInterpretWithOptions (t , //nolint:staticcheck
3012+ inter , err := parseCheckAndPrepareWithOptions (t ,
30143013 `
30153014 fun test() {
30163015 // "dog"
@@ -3046,8 +3045,24 @@ func TestInterpretComputationMeteringRLP(t *testing.T) {
30463045 _ , err = inter .Invoke ("test" )
30473046 require .NoError (t , err )
30483047
3049- AssertEqualWithDiff (t ,
3050- []common.ComputationUsage {
3048+ var expectedUsages []common.ComputationUsage
3049+ if * compile {
3050+ // The compiler/VM meters the function invocation after the
3051+ // argument array has been constructed and transferred.
3052+ expectedUsages = []common.ComputationUsage {
3053+ {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
3054+ {Kind : common .ComputationKindStatement , Intensity : 1 },
3055+ {Kind : common .ComputationKindCreateArrayValue , Intensity : 1 },
3056+ {Kind : common .ComputationKindAtreeArrayBatchConstruction , Intensity : 4 },
3057+ {Kind : common .ComputationKindTransferArrayValue , Intensity : 4 },
3058+ {Kind : common .ComputationKindAtreeArraySingleSlabConstruction , Intensity : 4 },
3059+ {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
3060+ {Kind : common .ComputationKindSTDLIBRLPDecodeString , Intensity : 4 },
3061+ {Kind : common .ComputationKindCreateArrayValue , Intensity : 1 },
3062+ {Kind : common .ComputationKindAtreeArraySingleSlabConstruction , Intensity : 3 },
3063+ }
3064+ } else {
3065+ expectedUsages = []common.ComputationUsage {
30513066 {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
30523067 {Kind : common .ComputationKindStatement , Intensity : 1 },
30533068 {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
@@ -3058,7 +3073,11 @@ func TestInterpretComputationMeteringRLP(t *testing.T) {
30583073 {Kind : common .ComputationKindSTDLIBRLPDecodeString , Intensity : 4 },
30593074 {Kind : common .ComputationKindCreateArrayValue , Intensity : 1 },
30603075 {Kind : common .ComputationKindAtreeArraySingleSlabConstruction , Intensity : 3 },
3061- },
3076+ }
3077+ }
3078+
3079+ AssertEqualWithDiff (t ,
3080+ expectedUsages ,
30623081 computationGauge .usages ,
30633082 )
30643083 })
@@ -3076,8 +3095,7 @@ func TestInterpretComputationMeteringRLP(t *testing.T) {
30763095
30773096 storage := NewUnmeteredInMemoryStorage ()
30783097
3079- // TODO: Also run with compiler
3080- inter , err := parseCheckAndInterpretWithOptions (t , //nolint:staticcheck
3098+ inter , err := parseCheckAndPrepareWithOptions (t ,
30813099 `
30823100 fun test() {
30833101 // "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce porta malesuada imperdiet. Sed erat erat, aliquam sed volutpat sed, volutpat ac sapien. Pellentesque sit amet arcu ut magna vehicula finibus non eu felis. Etiam sed tellus congue, sodales ante eget, dictum eros. In at metus sapien fusce."
@@ -3113,8 +3131,25 @@ func TestInterpretComputationMeteringRLP(t *testing.T) {
31133131 _ , err = inter .Invoke ("test" )
31143132 require .NoError (t , err )
31153133
3116- AssertEqualWithDiff (t ,
3117- []common.ComputationUsage {
3134+ var expectedUsages []common.ComputationUsage
3135+ if * compile {
3136+ // The compiler/VM meters the function invocation after the
3137+ // argument array has been constructed and transferred.
3138+ expectedUsages = []common.ComputationUsage {
3139+ {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
3140+ {Kind : common .ComputationKindStatement , Intensity : 1 },
3141+ {Kind : common .ComputationKindCreateArrayValue , Intensity : 1 },
3142+ {Kind : common .ComputationKindAtreeArrayBatchConstruction , Intensity : 303 },
3143+ {Kind : common .ComputationKindTransferArrayValue , Intensity : 303 },
3144+ {Kind : common .ComputationKindAtreeArrayBatchConstruction , Intensity : 303 },
3145+ {Kind : common .ComputationKindAtreeArrayReadIteration , Intensity : 303 },
3146+ {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
3147+ {Kind : common .ComputationKindSTDLIBRLPDecodeString , Intensity : 303 },
3148+ {Kind : common .ComputationKindCreateArrayValue , Intensity : 1 },
3149+ {Kind : common .ComputationKindAtreeArrayBatchConstruction , Intensity : 300 },
3150+ }
3151+ } else {
3152+ expectedUsages = []common.ComputationUsage {
31183153 {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
31193154 {Kind : common .ComputationKindStatement , Intensity : 1 },
31203155 {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
@@ -3126,7 +3161,11 @@ func TestInterpretComputationMeteringRLP(t *testing.T) {
31263161 {Kind : common .ComputationKindSTDLIBRLPDecodeString , Intensity : 303 },
31273162 {Kind : common .ComputationKindCreateArrayValue , Intensity : 1 },
31283163 {Kind : common .ComputationKindAtreeArrayBatchConstruction , Intensity : 300 },
3129- },
3164+ }
3165+ }
3166+
3167+ AssertEqualWithDiff (t ,
3168+ expectedUsages ,
31303169 computationGauge .usages ,
31313170 )
31323171 })
@@ -3144,8 +3183,7 @@ func TestInterpretComputationMeteringRLP(t *testing.T) {
31443183
31453184 storage := NewUnmeteredInMemoryStorage ()
31463185
3147- // TODO: Also run with compiler
3148- inter , err := parseCheckAndInterpretWithOptions (t , //nolint:staticcheck
3186+ inter , err := parseCheckAndPrepareWithOptions (t ,
31493187 `
31503188 fun test() {
31513189 // [['a']]
@@ -3181,8 +3219,26 @@ func TestInterpretComputationMeteringRLP(t *testing.T) {
31813219 _ , err = inter .Invoke ("test" )
31823220 require .NoError (t , err )
31833221
3184- AssertEqualWithDiff (t ,
3185- []common.ComputationUsage {
3222+ var expectedUsages []common.ComputationUsage
3223+ if * compile {
3224+ // The compiler/VM meters the function invocation after the
3225+ // argument array has been constructed and transferred.
3226+ expectedUsages = []common.ComputationUsage {
3227+ {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
3228+ {Kind : common .ComputationKindStatement , Intensity : 1 },
3229+ {Kind : common .ComputationKindCreateArrayValue , Intensity : 1 },
3230+ {Kind : common .ComputationKindAtreeArrayBatchConstruction , Intensity : 2 },
3231+ {Kind : common .ComputationKindTransferArrayValue , Intensity : 2 },
3232+ {Kind : common .ComputationKindAtreeArraySingleSlabConstruction , Intensity : 2 },
3233+ {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
3234+ {Kind : common .ComputationKindSTDLIBRLPDecodeList , Intensity : 2 },
3235+ {Kind : common .ComputationKindCreateArrayValue , Intensity : 1 },
3236+ {Kind : common .ComputationKindAtreeArrayBatchConstruction , Intensity : 1 },
3237+ {Kind : common .ComputationKindCreateArrayValue , Intensity : 1 },
3238+ {Kind : common .ComputationKindAtreeArraySingleSlabConstruction , Intensity : 1 },
3239+ }
3240+ } else {
3241+ expectedUsages = []common.ComputationUsage {
31863242 {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
31873243 {Kind : common .ComputationKindStatement , Intensity : 1 },
31883244 {Kind : common .ComputationKindFunctionInvocation , Intensity : 1 },
@@ -3195,7 +3251,11 @@ func TestInterpretComputationMeteringRLP(t *testing.T) {
31953251 {Kind : common .ComputationKindAtreeArrayBatchConstruction , Intensity : 1 },
31963252 {Kind : common .ComputationKindCreateArrayValue , Intensity : 1 },
31973253 {Kind : common .ComputationKindAtreeArraySingleSlabConstruction , Intensity : 1 },
3198- },
3254+ }
3255+ }
3256+
3257+ AssertEqualWithDiff (t ,
3258+ expectedUsages ,
31993259 computationGauge .usages ,
32003260 )
32013261 })
0 commit comments