-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
from
in evm_address
to make a mut
local copy of the bits
…
…argument before calling `mcli` (#2227) * fixing evm_address to make a local copy of bits before calling mcli * Add missing lock file * split into two tests
- Loading branch information
1 parent
88d8592
commit e705caa
Showing
11 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out | ||
target |
14 changes: 14 additions & 0 deletions
14
test/src/sdk-harness/test_artifacts/evm_test_abi/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-DD6C78AF57ACC141' | ||
dependencies = [] | ||
|
||
[[package]] | ||
name = 'evm_test_abi' | ||
source = 'root' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-DD6C78AF57ACC141' | ||
dependencies = ['core'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <contact@fuel.sh>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "evm_test_abi" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../sway-lib-std" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
library evm_test_abi; | ||
|
||
use std::vm::evm::evm_address::EvmAddress; | ||
|
||
abi EvmTest { | ||
fn evm_address_from_literal() -> EvmAddress; | ||
fn evm_address_from_argument(raw_address: b256) -> EvmAddress; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-4947D78C815C1154' | ||
dependencies = [] | ||
|
||
[[package]] | ||
name = 'evm' | ||
source = 'root' | ||
dependencies = [ | ||
'evm_test_abi', | ||
'std', | ||
] | ||
|
||
[[package]] | ||
name = 'evm_test_abi' | ||
source = 'path+from-root-4947D78C815C1154' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-4947D78C815C1154' | ||
dependencies = ['core'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[project] | ||
authors = ["Fuel Labs <contact@fuel.sh>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "evm" | ||
|
||
[dependencies] | ||
evm_test_abi = { path = "../../test_artifacts/evm_test_abi" } | ||
std = { path = "../../../../../sway-lib-std" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use fuels::{prelude::*, tx::ContractId}; | ||
|
||
abigen!( | ||
EvmTestContract, | ||
"test_projects/evm/out/debug/evm-abi.json" | ||
); | ||
|
||
async fn get_evm_test_instance() -> (EvmTestContract, ContractId) { | ||
let wallet = launch_provider_and_get_single_wallet().await; | ||
let id = Contract::deploy( | ||
"test_projects/evm/out/debug/evm.bin", | ||
&wallet, | ||
TxParameters::default(), | ||
) | ||
.await | ||
.unwrap(); | ||
let instance = EvmTestContract::new(id.to_string(), wallet); | ||
|
||
(instance, id) | ||
} | ||
|
||
#[tokio::test] | ||
async fn can_call_from_literal() { | ||
let (instance, _) = get_evm_test_instance().await; | ||
|
||
let raw_address = [6; 32]; // hardcoded in the contract to test calling `from()` with a literal | ||
let result = instance.evm_address_from_literal().call().await.unwrap(); | ||
assert_eq!(result.value.value[0..12], [0; 12]); | ||
assert_eq!(result.value.value[12..32], raw_address[12..32]); | ||
} | ||
|
||
#[tokio::test] | ||
async fn can_call_from_argument() { | ||
let (instance, _) = get_evm_test_instance().await; | ||
|
||
let raw_address = [7; 32]; | ||
let result = instance.evm_address_from_argument(raw_address.into()).call().await.unwrap(); | ||
assert_eq!(result.value.value[0..12], [0; 12]); | ||
assert_eq!(result.value.value[12..32], raw_address[12..32]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
contract; | ||
|
||
use evm_test_abi::EvmTest; | ||
use std::vm::evm::evm_address::EvmAddress; | ||
|
||
impl EvmTest for Contract { | ||
fn evm_address_from_literal() -> EvmAddress { | ||
~EvmAddress::from(0x0606060606060606060606060606060606060606060606060606060606060606) | ||
} | ||
|
||
fn evm_address_from_argument(raw_address: b256) -> EvmAddress { | ||
~EvmAddress::from(raw_address) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
mod auth; | ||
mod call_frames; | ||
mod context; | ||
mod evm; | ||
mod exponentiation; | ||
mod hashing; | ||
mod logging; | ||
|