Skip to content

Commit

Permalink
test: 💍 add u256 storage test
Browse files Browse the repository at this point in the history
  • Loading branch information
YancyParker committed Mar 13, 2024
1 parent 946f0b2 commit 4d08adf
Show file tree
Hide file tree
Showing 11 changed files with 894 additions and 6 deletions.
14 changes: 12 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions assembler/src/test_data_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ mod tests {
generate_from_file("u256_basic_asm.json".to_string(), "u256_basic.json".to_string());
}

#[test]
fn generate_storage_u256() {
generate_from_file("storage_u256_asm.json".to_string(), "storage_u256.json".to_string());
}

fn generate_from_file(input_file_name: String, output_file_name: String) {
let _ = fs::create_dir_all("test_data/bin/sccall");
let input_path = format!("test_data/asm/{}", input_file_name);
Expand Down
152 changes: 152 additions & 0 deletions assembler/test_data/abi/storage_u256_abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
[
{
"name": "set_value",
"type": "function",
"inputs": [],
"outputs": []
},
{
"name": "storage_to_meory",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "u256"
}
]
},
{
"name": "get_value",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "u256"
}
]
},
{
"name": "set_age",
"type": "function",
"inputs": [
{
"name": "_age",
"type": "u256"
}
],
"outputs": []
},
{
"name": "get_age",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "u256"
}
]
},
{
"name": "set_key",
"type": "function",
"inputs": [
{
"name": "_key",
"type": "u256"
}
],
"outputs": []
},
{
"name": "get_key",
"type": "function",
"inputs": [
{
"name": "_index",
"type": "u32"
}
],
"outputs": [
{
"name": "",
"type": "u256"
}
]
},
{
"name": "remove_key",
"type": "function",
"inputs": [],
"outputs": []
},
{
"name": "set_person",
"type": "function",
"inputs": [
{
"name": "_age",
"type": "u256"
},
{
"name": "_height",
"type": "u256"
}
],
"outputs": []
},
{
"name": "get_person",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "tuple",
"components": [
{
"name": "age",
"type": "u256"
},
{
"name": "height",
"type": "u256"
}
]
}
]
},
{
"name": "set_map",
"type": "function",
"inputs": [
{
"name": "_key",
"type": "u256"
},
{
"name": "_value",
"type": "u256"
}
],
"outputs": []
},
{
"name": "get_map",
"type": "function",
"inputs": [
{
"name": "_key",
"type": "u256"
}
],
"outputs": [
{
"name": "",
"type": "u256"
}
]
}
]
287 changes: 287 additions & 0 deletions assembler/test_data/asm/storage_u256_asm.json

Large diffs are not rendered by default.

287 changes: 287 additions & 0 deletions assembler/test_data/bin/storage_u256_asm.json

Large diffs are not rendered by default.

121 changes: 121 additions & 0 deletions assembler/test_data/bin/u256_basic.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ secp256k1 = { version = "0.28.1", default-features = false, features = ["hashes-
num = "0.4.1"

[dev-dependencies]
ola-lang-abi = "1.0.5"
ola-lang-abi = "1.0.7"
28 changes: 28 additions & 0 deletions executor/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2013,3 +2013,31 @@ fn u256_baisc_test() {
}
}


#[test]
fn u256_baisc_test() {
let abi: Abi = {
let file = File::open("../assembler/test_data/abi/storage_u256_abi.json")
.expect("failed to open ABI file");

serde_json::from_reader(file).expect("failed to parse ABI")
};

{
let func = abi.functions[0].clone();
let input = abi.encode_input_with_signature(func.signature().as_str(), &[]).unwrap();
println!("input_0:{:?}", input);

let calldata_0 = input
.iter()
.map(|e| GoldilocksField::from_canonical_u64(*e))
.collect();
executor_run_test_program(
"../assembler/test_data/bin/storage_u256.json",
"storage_u256_trace.txt",
false,
Some(calldata_0),
);
}
}

2 changes: 1 addition & 1 deletion mini-ola/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ clap_complete = "4.4.4"
anyhow = "1.0.75"
thiserror = "1.0"
hex = "0.4.3"
ola-lang-abi = "1.0.5"
ola-lang-abi = "1.0.7"
shellexpand = "3.1.0"
colored = "2.0.0"
core = { package = "core", path = "../core" }
Expand Down
1 change: 0 additions & 1 deletion plonky2/field/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#![allow(clippy::return_self_not_must_use)]
#![feature(generic_const_exprs)]
#![feature(specialization)]
#![feature(stdsimd)]

pub(crate) mod arch;
pub mod batch_util;
Expand Down
1 change: 0 additions & 1 deletion plonky2/plonky2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#![allow(clippy::return_self_not_must_use)]
#![feature(generic_const_exprs)]
#![feature(specialization)]
#![feature(stdsimd)]

extern crate alloc;

Expand Down

0 comments on commit 4d08adf

Please sign in to comment.