Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
Remove explicit max_gas_allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
cmichi committed Jun 28, 2021
1 parent f483460 commit 172342c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/tests/contract_terminate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async fn contract_terminate_works(mut canvas_ui: CanvasUi) -> Result<()> {

// when
let events = canvas_ui
.execute_transaction(Call::new(&contract_addr, "terminate_me").max_gas("5000"))
.execute_transaction(Call::new(&contract_addr, "terminate_me"))
.await
.expect("failed to execute transaction");
assert!(events.contains("system.KilledAccount"));
Expand All @@ -48,7 +48,7 @@ async fn contract_terminate_works(mut canvas_ui: CanvasUi) -> Result<()> {

// then
let err = canvas_ui
.execute_transaction(Call::new(&contract_addr, "terminate_me").max_gas("5000"))
.execute_transaction(Call::new(&contract_addr, "terminate_me"))
.await
.expect_err("successfully executed transaction, but expected it to_fail");
match err {
Expand Down
5 changes: 1 addition & 4 deletions src/tests/contract_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async fn contract_must_transfer_value_to_sender(mut canvas_ui: CanvasUi) -> Resu
.execute_transaction(
Call::new(&contract_addr, "give_me")
.push_value("value", "100")
.max_gas("25000")
.caller("BOB"),
)
.await
Expand All @@ -67,9 +66,7 @@ async fn transfer_exactly_ten_to_contract(mut canvas_ui: CanvasUi) -> Result<()>
// when
let result = canvas_ui
.execute_transaction(
Call::new(&contract_addr, "was_it_ten")
.payment("10", "pico")
.max_gas("25000"),
Call::new(&contract_addr, "was_it_ten").payment("10", "pico"),
)
.await;

Expand Down
18 changes: 6 additions & 12 deletions src/tests/delegator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,43 +68,37 @@ async fn delegator_works(mut canvas_ui: CanvasUi) -> Result<()> {
.await?;

// then
// this should work without having to set the `max_gas_allowed` explicitly here!
// can be removed once https://github.com/paritytech/canvas-ui/issues/95 has been fixed.
assert_eq!(
canvas_ui
.execute_rpc(Call::new(&delegator_addr, "get").max_gas("5000"))
.execute_rpc(Call::new(&delegator_addr, "get"))
.await?,
"0"
);
canvas_ui
.execute_transaction(
Call::new(&delegator_addr, "change")
.push_value("by: i32", "13")
.max_gas("5000"),
Call::new(&delegator_addr, "change").push_value("by: i32", "13"),
)
.await
.expect("failed to execute transaction");
assert_eq!(
canvas_ui
.execute_rpc(Call::new(&delegator_addr, "get").max_gas("5000"))
.execute_rpc(Call::new(&delegator_addr, "get"))
.await?,
"13"
);
canvas_ui
.execute_transaction(Call::new(&delegator_addr, "switch").max_gas("5000"))
.execute_transaction(Call::new(&delegator_addr, "switch"))
.await
.expect("failed to execute transaction");
canvas_ui
.execute_transaction(
Call::new(&delegator_addr, "change")
.push_value("by: i32", "3")
.max_gas("5000"),
Call::new(&delegator_addr, "change").push_value("by: i32", "3"),
)
.await
.expect("failed to execute transaction");
assert_eq!(
canvas_ui
.execute_rpc(Call::new(&delegator_addr, "get").max_gas("5000"))
.execute_rpc(Call::new(&delegator_addr, "get"))
.await?,
"10"
);
Expand Down
12 changes: 3 additions & 9 deletions src/tests/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ async fn dns_works(mut canvas_ui: CanvasUi) -> Result<()> {
Call::new(&contract_addr, "set_address")
.caller("ALICE")
.push_value("name", name)
.push_value("newAddress", address)
.max_gas("25000"),
.push_value("newAddress", address),
)
.await
.expect("failed to execute `set_address` transaction");
Expand All @@ -65,7 +64,6 @@ async fn dns_works(mut canvas_ui: CanvasUi) -> Result<()> {
Call::new(&contract_addr, "get_address")
.caller("EVE")
.push_value("name", name)
.max_gas("5000")
)
.await?,
address
Expand All @@ -79,7 +77,6 @@ async fn dns_works(mut canvas_ui: CanvasUi) -> Result<()> {
.caller("BOB")
.push_value("name", name)
.push_value("new_address", address2)
.max_gas("25000")
)
.await
.is_err());
Expand All @@ -90,8 +87,7 @@ async fn dns_works(mut canvas_ui: CanvasUi) -> Result<()> {
Call::new(&contract_addr, "transfer")
.caller("ALICE")
.push_value("name", name)
.push_value("to", "BOB")
.max_gas("25000"),
.push_value("to", "BOB"),
)
.await
.expect("failed to execute `transfer` to BOB transaction");
Expand All @@ -100,8 +96,7 @@ async fn dns_works(mut canvas_ui: CanvasUi) -> Result<()> {
Call::new(&contract_addr, "set_address")
.caller("BOB")
.push_value("name", name)
.push_value("newAddress", address2)
.max_gas("25000"),
.push_value("newAddress", address2),
)
.await
.expect("failed to execute `set_address` transaction from BOB");
Expand All @@ -111,7 +106,6 @@ async fn dns_works(mut canvas_ui: CanvasUi) -> Result<()> {
Call::new(&contract_addr, "get_address")
.caller("EVE")
.push_value("name", name)
.max_gas("5000")
)
.await?,
address2
Expand Down
24 changes: 8 additions & 16 deletions src/tests/multisig_plain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ async fn multisig_works_with_flipper_transaction(mut canvas_ui: CanvasUi) -> Res
.push_value("selector", "0x633aa551") // `flip`
.push_value("input", "0x00")
.push_value("transferred_value", "0")
.push_value("gas_limit", "9999999000")
.max_gas("1199999"),
.push_value("gas_limit", "9999999000"),
)
.await
.expect("failed to execute `transfer` to BOB transaction");
Expand All @@ -68,8 +67,7 @@ async fn multisig_works_with_flipper_transaction(mut canvas_ui: CanvasUi) -> Res
.execute_transaction(
Call::new(&contract_addr, "confirm_transaction")
.caller("ALICE")
.push_value("transId", id)
.max_gas("60000"),
.push_value("transId", id),
)
.await
.expect("failed to execute `transfer` to BOB transaction");
Expand All @@ -78,8 +76,7 @@ async fn multisig_works_with_flipper_transaction(mut canvas_ui: CanvasUi) -> Res
.execute_transaction(
Call::new(&contract_addr, "confirm_transaction")
.caller("BOB")
.push_value("transId", id)
.max_gas("60000"),
.push_value("transId", id),
)
.await
.expect("failed to execute `transfer` to BOB transaction");
Expand All @@ -96,8 +93,7 @@ async fn multisig_works_with_flipper_transaction(mut canvas_ui: CanvasUi) -> Res
.execute_transaction(
Call::new(&contract_addr, "invoke_transaction")
.caller("ALICE")
.push_value("transId", id)
.max_gas("90000"),
.push_value("transId", id),
)
.await
.expect("failed to execute `transfer` to BOB transaction");
Expand Down Expand Up @@ -144,8 +140,7 @@ async fn multisig_works_with_payable_transaction(mut canvas_ui: CanvasUi) -> Res
.push_value("selector", "0xcafebabe") // `was_it_ten`
.push_value("input", "0x00")
.push_value("transferred_value", "10")
.push_value("gas_limit", "9999999000")
.max_gas("1199999"),
.push_value("gas_limit", "9999999000"),
)
.await
.expect("failed to execute `transfer` to BOB transaction");
Expand All @@ -154,8 +149,7 @@ async fn multisig_works_with_payable_transaction(mut canvas_ui: CanvasUi) -> Res
.execute_transaction(
Call::new(&contract_addr, "confirm_transaction")
.caller("ALICE")
.push_value("transId", id)
.max_gas("60000"),
.push_value("transId", id),
)
.await
.expect("failed to execute `transfer` to BOB transaction");
Expand All @@ -164,8 +158,7 @@ async fn multisig_works_with_payable_transaction(mut canvas_ui: CanvasUi) -> Res
.execute_transaction(
Call::new(&contract_addr, "confirm_transaction")
.caller("BOB")
.push_value("transId", id)
.max_gas("60000"),
.push_value("transId", id),
)
.await
.expect("failed to execute `transfer` to BOB transaction");
Expand All @@ -176,8 +169,7 @@ async fn multisig_works_with_payable_transaction(mut canvas_ui: CanvasUi) -> Res
Call::new(&contract_addr, "invoke_transaction")
.caller("ALICE")
.push_value("transId", id)
.payment("10", "pico")
.max_gas("90000"),
.payment("10", "pico"),
)
.await
.expect("failed to execute `transfer` to BOB transaction");
Expand Down

0 comments on commit 172342c

Please sign in to comment.