@@ -1083,7 +1083,11 @@ func TestTransactionFeeDeduction(t *testing.T) {
1083
1083
1084
1084
func TestSettingExecutionWeights (t * testing.T ) {
1085
1085
1086
+ // change the chain so that the metering settings are read from the service account
1087
+ chain := flow .Emulator .Chain ()
1088
+
1086
1089
t .Run ("transaction should fail with high weights" , newVMTest ().withBootstrapProcedureOptions (
1090
+
1087
1091
fvm .WithMinimumStorageReservation (fvm .DefaultMinimumStorageReservation ),
1088
1092
fvm .WithAccountCreationFee (fvm .DefaultAccountCreationFee ),
1089
1093
fvm .WithStorageMBPerFLOW (fvm .DefaultStorageMBPerFLOW ),
@@ -1092,6 +1096,8 @@ func TestSettingExecutionWeights(t *testing.T) {
1092
1096
common .ComputationKindLoop : 100_000 << meter .MeterExecutionInternalPrecisionBytes ,
1093
1097
},
1094
1098
),
1099
+ ).withContextOptions (
1100
+ fvm .WithChain (chain ),
1095
1101
).run (
1096
1102
func (t * testing.T , vm fvm.VM , chain flow.Chain , ctx fvm.Context , snapshotTree snapshot.SnapshotTree ) {
1097
1103
@@ -1140,6 +1146,7 @@ func TestSettingExecutionWeights(t *testing.T) {
1140
1146
),
1141
1147
).withContextOptions (
1142
1148
fvm .WithMemoryLimit (10_000_000_000 ),
1149
+ fvm .WithChain (chain ),
1143
1150
).run (
1144
1151
func (t * testing.T , vm fvm.VM , chain flow.Chain , ctx fvm.Context , snapshotTree snapshot.SnapshotTree ) {
1145
1152
// Create an account private key.
@@ -1190,6 +1197,7 @@ func TestSettingExecutionWeights(t *testing.T) {
1190
1197
),
1191
1198
).withContextOptions (
1192
1199
fvm .WithMemoryLimit (10_000_000_000 ),
1200
+ fvm .WithChain (chain ),
1193
1201
).run (
1194
1202
func (t * testing.T , vm fvm.VM , chain flow.Chain , ctx fvm.Context , snapshotTree snapshot.SnapshotTree ) {
1195
1203
@@ -1234,6 +1242,8 @@ func TestSettingExecutionWeights(t *testing.T) {
1234
1242
fvm .WithExecutionMemoryWeights (
1235
1243
memoryWeights ,
1236
1244
),
1245
+ ).withContextOptions (
1246
+ fvm .WithChain (chain ),
1237
1247
).run (
1238
1248
func (t * testing.T , vm fvm.VM , chain flow.Chain , ctx fvm.Context , snapshotTree snapshot.SnapshotTree ) {
1239
1249
privateKeys , err := testutil .GenerateAccountPrivateKeys (1 )
@@ -1301,6 +1311,8 @@ func TestSettingExecutionWeights(t *testing.T) {
1301
1311
environment .ComputationKindCreateAccount : (fvm .DefaultComputationLimit + 1 ) << meter .MeterExecutionInternalPrecisionBytes ,
1302
1312
},
1303
1313
),
1314
+ ).withContextOptions (
1315
+ fvm .WithChain (chain ),
1304
1316
).run (
1305
1317
func (t * testing.T , vm fvm.VM , chain flow.Chain , ctx fvm.Context , snapshotTree snapshot.SnapshotTree ) {
1306
1318
txBody := flow .NewTransactionBody ().
@@ -1337,6 +1349,8 @@ func TestSettingExecutionWeights(t *testing.T) {
1337
1349
environment .ComputationKindCreateAccount : 100_000_000 << meter .MeterExecutionInternalPrecisionBytes ,
1338
1350
},
1339
1351
),
1352
+ ).withContextOptions (
1353
+ fvm .WithChain (chain ),
1340
1354
).run (
1341
1355
func (t * testing.T , vm fvm.VM , chain flow.Chain , ctx fvm.Context , snapshotTree snapshot.SnapshotTree ) {
1342
1356
@@ -1374,6 +1388,8 @@ func TestSettingExecutionWeights(t *testing.T) {
1374
1388
environment .ComputationKindCreateAccount : 100_000_000 << meter .MeterExecutionInternalPrecisionBytes ,
1375
1389
},
1376
1390
),
1391
+ ).withContextOptions (
1392
+ fvm .WithChain (chain ),
1377
1393
).run (
1378
1394
func (t * testing.T , vm fvm.VM , chain flow.Chain , ctx fvm.Context , snapshotTree snapshot.SnapshotTree ) {
1379
1395
txBody := flow .NewTransactionBody ().
@@ -1417,6 +1433,7 @@ func TestSettingExecutionWeights(t *testing.T) {
1417
1433
fvm .WithAccountStorageLimit (true ),
1418
1434
fvm .WithTransactionFeesEnabled (true ),
1419
1435
fvm .WithMemoryLimit (math .MaxUint64 ),
1436
+ fvm .WithChain (chain ),
1420
1437
).run (
1421
1438
func (t * testing.T , vm fvm.VM , chain flow.Chain , ctx fvm.Context , snapshotTree snapshot.SnapshotTree ) {
1422
1439
// Use the maximum amount of computation so that the transaction still passes.
@@ -1510,6 +1527,7 @@ func TestSettingExecutionWeights(t *testing.T) {
1510
1527
fvm .WithAccountStorageLimit (true ),
1511
1528
fvm .WithTransactionFeesEnabled (true ),
1512
1529
fvm .WithMemoryLimit (math .MaxUint64 ),
1530
+ fvm .WithChain (chain ),
1513
1531
).run (
1514
1532
func (t * testing.T , vm fvm.VM , chain flow.Chain , ctx fvm.Context , snapshotTree snapshot.SnapshotTree ) {
1515
1533
// Create an account private key.
@@ -2165,6 +2183,8 @@ func TestScriptExecutionLimit(t *testing.T) {
2165
2183
2166
2184
t .Parallel ()
2167
2185
2186
+ chain := flow .Emulator .Chain ()
2187
+
2168
2188
script := fvm .Script ([]byte (`
2169
2189
access(all) fun main() {
2170
2190
var s: Int256 = 1024102410241024
@@ -2206,6 +2226,7 @@ func TestScriptExecutionLimit(t *testing.T) {
2206
2226
fvm .WithTransactionFeesEnabled (true ),
2207
2227
fvm .WithAccountStorageLimit (true ),
2208
2228
fvm .WithComputationLimit (10000 ),
2229
+ fvm .WithChain (chain ),
2209
2230
).run (
2210
2231
func (t * testing.T , vm fvm.VM , chain flow.Chain , ctx fvm.Context , snapshotTree snapshot.SnapshotTree ) {
2211
2232
scriptCtx := fvm .NewContextFromParent (ctx )
@@ -2228,6 +2249,7 @@ func TestScriptExecutionLimit(t *testing.T) {
2228
2249
fvm .WithTransactionFeesEnabled (true ),
2229
2250
fvm .WithAccountStorageLimit (true ),
2230
2251
fvm .WithComputationLimit (20000 ),
2252
+ fvm .WithChain (chain ),
2231
2253
).run (
2232
2254
func (t * testing.T , vm fvm.VM , chain flow.Chain , ctx fvm.Context , snapshotTree snapshot.SnapshotTree ) {
2233
2255
scriptCtx := fvm .NewContextFromParent (ctx )
0 commit comments