@@ -26,7 +26,6 @@ import (
26
26
"github.com/onflow/cadence/test_utils/runtime_utils"
27
27
"github.com/onflow/crypto"
28
28
"github.com/onflow/flow-core-contracts/lib/go/contracts"
29
- "github.com/onflow/flow-core-contracts/lib/go/templates"
30
29
bridge "github.com/onflow/flow-evm-bridge"
31
30
flowsdk "github.com/onflow/flow-go-sdk"
32
31
"github.com/onflow/flow-go-sdk/test"
@@ -3144,16 +3143,7 @@ func TestVMBridge(t *testing.T) {
3144
3143
3145
3144
sc := systemcontracts .SystemContractsForChain (chain .ChainID ())
3146
3145
3147
- env := templates.Environment {
3148
- ServiceAccountAddress : chain .ServiceAddress ().String (),
3149
- FungibleTokenAddress : sc .FungibleToken .Address .Hex (),
3150
- FlowTokenAddress : sc .FlowToken .Address .Hex (),
3151
- EVMAddress : sc .EVMContract .Address .Hex (),
3152
- ViewResolverAddress : chain .ServiceAddress ().String (),
3153
- FungibleTokenMetadataViewsAddress : sc .FungibleToken .Address .Hex (),
3154
- MetadataViewsAddress : sc .NonFungibleToken .Address .Hex (),
3155
- BurnerAddress : chain .ServiceAddress ().String (),
3156
- }
3146
+ env := sc .AsTemplateEnv ()
3157
3147
3158
3148
bridgeEnv := bridge.Environment {
3159
3149
CrossVMNFTAddress : env .ServiceAccountAddress ,
@@ -3195,25 +3185,21 @@ func TestVMBridge(t *testing.T) {
3195
3185
chain )
3196
3186
require .NoError (t , err )
3197
3187
3198
- txBody := transferTokensTx (chain ).
3199
- AddAuthorizer (chain .ServiceAddress ()).
3200
- AddArgument (jsoncdc .MustEncode (cadence .UFix64 (2.0 ))).
3201
- AddArgument (jsoncdc .MustEncode (cadence .NewAddress (accounts [0 ])))
3202
-
3203
- txBody .SetProposalKey (chain .ServiceAddress (), 0 , 0 )
3204
- txBody .SetPayer (chain .ServiceAddress ())
3205
-
3206
- err = testutil .SignEnvelope (
3207
- txBody ,
3188
+ txBody := blueprints .TransferFlowTokenTransaction (
3208
3189
chain .ServiceAddress (),
3209
- unittest .ServiceAccountPrivateKey ,
3190
+ accounts [0 ],
3191
+ "2.0" ,
3192
+ env ,
3210
3193
)
3194
+
3195
+ err = testutil .SignTransactionAsServiceAccount (txBody , 0 , chain )
3211
3196
require .NoError (t , err )
3212
3197
3213
3198
executionSnapshot , output , err := vm .Run (
3214
3199
ctx ,
3215
3200
fvm .Transaction (txBody , 0 ),
3216
3201
snapshotTree )
3202
+
3217
3203
require .NoError (t , err )
3218
3204
require .NoError (t , output .Err )
3219
3205
@@ -3382,18 +3368,7 @@ func TestVMBridge(t *testing.T) {
3382
3368
3383
3369
sc := systemcontracts .SystemContractsForChain (chain .ChainID ())
3384
3370
3385
- env := templates.Environment {
3386
- ServiceAccountAddress : chain .ServiceAddress ().String (),
3387
- FungibleTokenAddress : sc .FungibleToken .Address .Hex (),
3388
- FlowTokenAddress : sc .FlowToken .Address .Hex (),
3389
- EVMAddress : sc .EVMContract .Address .Hex (),
3390
- ViewResolverAddress : chain .ServiceAddress ().String (),
3391
- FungibleTokenMetadataViewsAddress : sc .FungibleToken .Address .Hex (),
3392
- MetadataViewsAddress : sc .NonFungibleToken .Address .Hex (),
3393
- NonFungibleTokenAddress : sc .NonFungibleToken .Address .Hex (),
3394
- CrossVMMetadataViewsAddress : sc .NonFungibleToken .Address .Hex (),
3395
- BurnerAddress : chain .ServiceAddress ().String (),
3396
- }
3371
+ env := sc .AsTemplateEnv ()
3397
3372
3398
3373
bridgeEnv := bridge.Environment {
3399
3374
CrossVMNFTAddress : env .ServiceAccountAddress ,
@@ -3435,25 +3410,21 @@ func TestVMBridge(t *testing.T) {
3435
3410
chain )
3436
3411
require .NoError (t , err )
3437
3412
3438
- txBody := transferTokensTx (chain ).
3439
- AddAuthorizer (chain .ServiceAddress ()).
3440
- AddArgument (jsoncdc .MustEncode (cadence .UFix64 (2.0 ))).
3441
- AddArgument (jsoncdc .MustEncode (cadence .NewAddress (accounts [0 ])))
3442
-
3443
- txBody .SetProposalKey (chain .ServiceAddress (), 0 , 0 )
3444
- txBody .SetPayer (chain .ServiceAddress ())
3445
-
3446
- err = testutil .SignEnvelope (
3447
- txBody ,
3413
+ txBody := blueprints .TransferFlowTokenTransaction (
3448
3414
chain .ServiceAddress (),
3449
- unittest .ServiceAccountPrivateKey ,
3415
+ accounts [0 ],
3416
+ "2.0" ,
3417
+ env ,
3450
3418
)
3419
+
3420
+ err = testutil .SignTransactionAsServiceAccount (txBody , 0 , chain )
3451
3421
require .NoError (t , err )
3452
3422
3453
3423
executionSnapshot , output , err := vm .Run (
3454
3424
ctx ,
3455
3425
fvm .Transaction (txBody , 0 ),
3456
3426
snapshotTree )
3427
+
3457
3428
require .NoError (t , err )
3458
3429
require .NoError (t , output .Err )
3459
3430
0 commit comments