-
Notifications
You must be signed in to change notification settings - Fork 9
Add tests for create2 in creator #51
Changes from 4 commits
41a4ad6
8d8f419
721064d
a2202e0
09641d2
ab5407a
d05e071
c24257c
986a6fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| #!/bin/bash | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
| TEST_NAME=$1 | ||
| ADDITIONAL_FEATURES=$2 | ||
|
|
||
| cargo run --manifest-path ./gen/Cargo.toml -- $TEST_NAME | ||
| cargo run --manifest-path ./gen/Cargo.toml -- $TEST_NAME $ADDITIONAL_FEATURES | ||
| RUSTFLAGS="-C link-arg=-z -C link-arg=stack-size=65536" CARGO_TARGET_DIR=./target cargo build --manifest-path=./target/tests/$TEST_NAME/Cargo.toml --release --target=wasm32-unknown-unknown | ||
| wasm-build ./target $TEST_NAME --target wasm32-unknown-unknown | ||
| cp ./target/$TEST_NAME.wasm ./compiled | ||
| wasm-build ./target $TEST_NAME --save-raw ./target/$TEST_NAME.raw.wasm --target wasm32-unknown-unknown | ||
| cp ./target/$TEST_NAME.raw.wasm ./compiled/$TEST_NAME.wasm |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #!/bin/bash | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,23 +3,26 @@ use std::path::PathBuf; | |
|
|
||
| fn main() { | ||
| let args = env::args().collect::<Vec<_>>(); | ||
| if args.len() != 2 { | ||
| println!("Usage: {} gen <test.rs>", args[0]); | ||
| return; | ||
| } | ||
|
|
||
| let file_name = &args[1]; | ||
|
|
||
| let toml = r#" | ||
| let (file_name, pwasm_ethereum_version, pwasm_std_version) = match args.len() { | ||
| 2 => (&args[1], r#""0.5.0""#.to_string(), r#""0.9.0""#), | ||
| 3 => (&args[1], format!(r#"{{ git = "https://github.com/paritytech/pwasm-ethereum", branch = "kip4", features = [{}] }}"#, args[2].split(",").map(|s| format!(r#""{}""#, s)).collect::<Vec<_>>().join(", ")), r#""0.10.0""#), | ||
| _ => { | ||
| println!("Usage: {} gen <test.rs>", args[0]); | ||
| return; | ||
| }, | ||
| }; | ||
|
|
||
| let toml = format!(r#" | ||
| [package] | ||
| name = "wasm-tests" | ||
| version = "0.1.0" | ||
| authors = ["NikVolf <[email protected]>"] | ||
|
|
||
| [dependencies] | ||
| pwasm-std = "0.9.0" | ||
| pwasm-ethereum = "0.5.0" | ||
| bigint = { version = "4", default-features = false } | ||
| pwasm-std = {} | ||
| pwasm-ethereum = {} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could be just 0.6 ? |
||
| bigint = {{ version = "4", default-features = false }} | ||
| parity-hash = {{ version = "1", default-features = false }} | ||
|
|
||
| [lib] | ||
| name = "$file_name" | ||
|
|
@@ -30,7 +33,7 @@ crate-type = ["cdylib"] | |
| panic = "abort" | ||
| lto = true | ||
| opt-level = "z" | ||
| "#; | ||
| "#, pwasm_std_version, pwasm_ethereum_version); | ||
|
|
||
| let target_toml = toml.replace("$file_name", file_name); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,4 +12,7 @@ pub fn call() { | |
| data.extend_from_slice(&[5u8; 400*1024][..]); | ||
| data | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,3 +24,6 @@ pub fn call() { | |
|
|
||
| ret(&[]); | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,3 +37,6 @@ pub fn call() { | |
|
|
||
| ret(&res[..]); | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,3 +35,6 @@ pub fn call() { | |
| logger::debug("Exiting..."); | ||
| ret(&res[..]); | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,16 +2,33 @@ | |
|
|
||
| extern crate pwasm_std; | ||
| extern crate pwasm_ethereum; | ||
| extern crate bigint; | ||
| extern crate parity_hash as hash; | ||
|
|
||
| use pwasm_std::logger; | ||
| use pwasm_ethereum::{input, ret, create, value}; | ||
| use pwasm_ethereum::{input, ret, create, create2, value}; | ||
| use bigint::U256; | ||
| use hash::H256; | ||
|
|
||
| #[no_mangle] | ||
| pub fn call() { | ||
| if let Ok(addr) = create(value(), &input()) { | ||
| logger::debug("Created contractwith code"); | ||
| ret(&addr[..]); | ||
| let mut r = [0u8; 40]; | ||
| if let Ok(addr) = create(value() / U256::from(2), &input()) { | ||
| logger::debug("Created contract with code"); | ||
| (&mut r[0..20]).copy_from_slice(&addr[..]); | ||
| } else { | ||
| logger::debug("Error creating contract"); | ||
| } | ||
|
|
||
| if let Ok(addr) = create2(value() / U256::from(2), H256::default(), &input()) { | ||
|
||
| logger::debug("Created contract with code and salt"); | ||
| (&mut r[0..20]).copy_from_slice(&addr[..]); | ||
| } else { | ||
| logger::debug("Error creating contract"); | ||
| } | ||
|
|
||
| ret(&r[..]); | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,4 +23,7 @@ pub fn call() { | |
| } | ||
|
|
||
| ret(&dispersed[..]) | ||
| } | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,3 +34,6 @@ pub fn call() { | |
|
|
||
| ext::ret(&output); | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,6 @@ use pwasm_ethereum::{ret, input}; | |
| pub fn call() { | ||
| ret(&keccak(&input())); | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,4 +27,7 @@ pub fn call() { | |
|
|
||
| result_bytes | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,4 +15,7 @@ pub fn call() { | |
| } | ||
| data | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,3 +18,6 @@ pub fn call() { | |
| let val: [u8; 32] = get_value_from_key(1); | ||
| ret(&val[..]) | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,4 +17,7 @@ pub fn call() { | |
| } else { | ||
| ret(&input); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn deploy() { } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could just be updated to 0.10 for all?