Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gists-immunefi/485dee55dd72ebc31c483bde46385587 to your computer and use it in GitHub Desktop.
Save gists-immunefi/485dee55dd72ebc31c483bde46385587 to your computer and use it in GitHub Desktop.
#[tokio::test]
async fn pow_bug() {
//Setup
let (instance, _id) = get_contract_instance().await;
println!("------------u8 pow function overflow----------------");
let asset_id = instance.methods().demonstrate_bug_u8(Identity::Address(instance.account().address().into()), 20)
.append_variable_outputs(1)
.call()
.await
.unwrap()
.value;
let balance = instance.account().get_asset_balance(&asset_id).await.unwrap();
println!("balance: {:#?}", balance);
println!("------------u32 pow function overflow----------------");
let coins_to_keep = instance.methods().demonstrate_bug_u32(1000).call().await.unwrap().value;
println!("coins_to_keep: {:#?}", coins_to_keep);
let coins_before = instance.account().get_coins(AssetId::zeroed()).await.unwrap()[0].amount;
println!("coins_before: {:#?}", coins_before);
instance.account().transfer(
&Bech32Address::from_str("fuel1glsm9rc8ysh9yjt8ljkuatalvdad3rs3wpqjznd3p7daydw2gg6sftwvvr").unwrap(),
coins_before - TryInto::<u64>::try_into(coins_to_keep).unwrap(),
AssetId::zeroed(),
TxPolicies::default()
).await.unwrap();
let coins_after = instance.account().get_coins(AssetId::zeroed()).await.unwrap()[0].amount;
println!("coins after: {:#?}", coins_after);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment