Skip to content

Commit 4574372

Browse files
authored
chore: fix some remaining todos regarding transaction fees (#1646)
1 parent 2c09e63 commit 4574372

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

e2e/tests/predicates.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,29 +1141,35 @@ async fn predicate_blobs() -> Result<()> {
11411141
// gonna make later on
11421142
// ANCHOR: uploading_the_blob
11431143
loader.upload_blob(extra_wallet).await?;
1144-
11451144
predicate.set_provider(provider.clone());
11461145

1147-
let expected_fee = 1;
1148-
predicate
1146+
let amount_to_send = 42;
1147+
let response = predicate
11491148
.transfer(
11501149
receiver.address(),
1151-
predicate_balance - expected_fee,
1150+
amount_to_send,
11521151
asset_id,
11531152
TxPolicies::default(),
11541153
)
11551154
.await?;
11561155
// ANCHOR_END: uploading_the_blob
11571156

11581157
// The predicate has spent the funds
1159-
assert_address_balance(predicate.address(), &provider, asset_id, 0).await;
1158+
let transaction_fee = response.tx_status.total_fee;
1159+
assert_address_balance(
1160+
predicate.address(),
1161+
&provider,
1162+
asset_id,
1163+
predicate_balance - amount_to_send - transaction_fee,
1164+
)
1165+
.await;
11601166

11611167
// Funds were transferred
11621168
assert_address_balance(
11631169
receiver.address(),
11641170
&provider,
11651171
asset_id,
1166-
receiver_balance + predicate_balance - expected_fee,
1172+
receiver_balance + amount_to_send,
11671173
)
11681174
.await;
11691175

@@ -1271,9 +1277,6 @@ async fn predicate_transfer_respects_maturity_and_expiration() -> Result<()> {
12711277
.with_expiration(expiration);
12721278
let amount_to_send = 10;
12731279

1274-
// TODO: https://github.com/FuelLabs/fuels-rs/issues/1394
1275-
let expected_fee = 1;
1276-
12771280
{
12781281
let err = predicate
12791282
.transfer(receiver.address(), amount_to_send, asset_id, tx_policies)
@@ -1282,13 +1285,15 @@ async fn predicate_transfer_respects_maturity_and_expiration() -> Result<()> {
12821285

12831286
assert!(err.to_string().contains("TransactionMaturity"));
12841287
}
1285-
{
1288+
let transaction_fee = {
12861289
provider.produce_blocks(15, None).await?;
12871290
predicate
12881291
.transfer(receiver.address(), amount_to_send, asset_id, tx_policies)
12891292
.await
1290-
.expect("should succeed. Block height between `maturity` and `expiration`");
1291-
}
1293+
.expect("should succeed. Block height between `maturity` and `expiration`")
1294+
.tx_status
1295+
.total_fee
1296+
};
12921297
{
12931298
provider.produce_blocks(15, None).await?;
12941299
let err = predicate
@@ -1304,7 +1309,7 @@ async fn predicate_transfer_respects_maturity_and_expiration() -> Result<()> {
13041309
predicate.address(),
13051310
&provider,
13061311
asset_id,
1307-
predicate_balance - amount_to_send - expected_fee,
1312+
predicate_balance - amount_to_send - transaction_fee,
13081313
)
13091314
.await;
13101315

e2e/tests/wallets.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,6 @@ async fn wallet_transfer_respects_maturity_and_expiration() -> Result<()> {
519519
.with_expiration(expiration);
520520
let amount_to_send = 10;
521521

522-
// TODO: https://github.com/FuelLabs/fuels-rs/issues/1394
523-
let expected_fee = 1;
524-
525522
{
526523
let err = wallet
527524
.transfer(&receiver, amount_to_send, asset_id, tx_policies)
@@ -530,13 +527,15 @@ async fn wallet_transfer_respects_maturity_and_expiration() -> Result<()> {
530527

531528
assert!(err.to_string().contains("TransactionMaturity"));
532529
}
533-
{
530+
let transaction_fee = {
534531
provider.produce_blocks(15, None).await?;
535532
wallet
536533
.transfer(&receiver, amount_to_send, asset_id, tx_policies)
537534
.await
538-
.expect("should succeed. Block height between `maturity` and `expiration`");
539-
}
535+
.expect("should succeed. Block height between `maturity` and `expiration`")
536+
.tx_status
537+
.total_fee
538+
};
540539
{
541540
provider.produce_blocks(15, None).await?;
542541
let err = wallet
@@ -552,7 +551,7 @@ async fn wallet_transfer_respects_maturity_and_expiration() -> Result<()> {
552551
wallet.address(),
553552
provider,
554553
asset_id,
555-
wallet_balance - amount_to_send - expected_fee,
554+
wallet_balance - amount_to_send - transaction_fee,
556555
)
557556
.await;
558557

0 commit comments

Comments
 (0)