diff --git a/tig-benchmarker/common/structs.py b/tig-benchmarker/common/structs.py index b5484e4..e4d4e94 100644 --- a/tig-benchmarker/common/structs.py +++ b/tig-benchmarker/common/structs.py @@ -104,7 +104,7 @@ class OutputData(FromDict): nonce: int runtime_signature: int fuel_consumed: int - solution: dict + solution: str cpu_arch: str def calc_solution_signature(self) -> int: diff --git a/tig-benchmarker/tests/data.py b/tig-benchmarker/tests/data.py index 7752c22..e12e387 100644 --- a/tig-benchmarker/tests/data.py +++ b/tig-benchmarker/tests/data.py @@ -10,20 +10,16 @@ from common.structs import BenchmarkSettings, OutputData class TestData(unittest.TestCase): def test_calc_solution_signature(self): - solution = { - "data_x": 42, - "data_y": "test" - } - output_data = OutputData( nonce=123, runtime_signature=456, fuel_consumed=789, - solution=solution + solution="test", + cpu_arch="AMD64" ) # Assert same as Rust version: tig-structs/tests/core.rs - self.assertEqual(output_data.calc_solution_signature(), 11549591319018095145) + self.assertEqual(output_data.calc_solution_signature(), 11204800550749450632) def test_calc_seed(self): settings = BenchmarkSettings( @@ -45,24 +41,20 @@ class TestData(unittest.TestCase): self.assertEqual(settings.calc_seed(rand_hash, nonce), expected) def test_outputdata_to_merklehash(self): - solution = { - "data_x": 42, - "data_y": "test" - } - output_data = OutputData( nonce=123, runtime_signature=456, fuel_consumed=789, - solution=solution + solution="test", + cpu_arch="AMD64" ) merkle_hash = output_data.to_merkle_hash() # Assert same as Rust version: tig-structs/tests/core.rs expected = MerkleHash(bytes([ - 207, 29, 184, 163, 158, 22, 137, 73, 72, 58, 24, 246, 67, 9, 44, 20, - 32, 22, 86, 206, 191, 5, 52, 241, 41, 113, 198, 85, 11, 53, 190, 57 + 79, 126, 186, 90, 12, 111, 100, 8, 120, 150, 225, 176, 200, 201, 125, 150, 58, 122, + 214, 216, 68, 6, 125, 247, 248, 4, 165, 185, 157, 44, 13, 151 ])) self.assertEqual(merkle_hash, expected) diff --git a/tig-structs/src/core.rs b/tig-structs/src/core.rs index 22ec973..81eee4d 100644 --- a/tig-structs/src/core.rs +++ b/tig-structs/src/core.rs @@ -303,12 +303,6 @@ serializable_struct_with_getters! { } // Code child structs -serializable_struct_with_getters! { - SourceCode { - rust: String, - cuda: Option, - } -} serializable_struct_with_getters! { CodeDetails { name: String, @@ -452,13 +446,12 @@ pub enum CPUArchitecture { AMD64, ARM64, } -pub type Solution = Map; serializable_struct_with_getters! { OutputData { nonce: u64, runtime_signature: u64, fuel_consumed: u64, - solution: Solution, + solution: String, cpu_arch: CPUArchitecture, } } diff --git a/tig-structs/tests/core.rs b/tig-structs/tests/core.rs index 928dd34..7136dcb 100644 --- a/tig-structs/tests/core.rs +++ b/tig-structs/tests/core.rs @@ -1,27 +1,18 @@ -use serde_json::json; use tig_structs::core::{BenchmarkSettings, CPUArchitecture, OutputData}; use tig_utils::MerkleHash; #[test] fn test_calc_solution_signature() { - let solution = json!({ - "data_x": 42, - "data_y": "test" - }) - .as_object() - .unwrap() - .clone(); - let output_data = OutputData { nonce: 123, runtime_signature: 456, fuel_consumed: 789, - solution: solution.clone(), + solution: "test".to_string(), cpu_arch: CPUArchitecture::AMD64, }; // Assert same as Python version: tig-benchmarker/tests/core.rs - assert_eq!(output_data.calc_solution_signature(), 11549591319018095145); + assert_eq!(output_data.calc_solution_signature(), 11204800550749450632); } #[test] @@ -49,19 +40,11 @@ fn test_calc_seed() { #[test] fn test_outputdata_to_merklehash() { - let solution = json!({ - "data_x": 42, - "data_y": "test" - }) - .as_object() - .unwrap() - .clone(); - let output_data = OutputData { nonce: 123, runtime_signature: 456, fuel_consumed: 789, - solution: solution.clone(), + solution: "test".to_string(), cpu_arch: CPUArchitecture::AMD64, }; @@ -71,8 +54,8 @@ fn test_outputdata_to_merklehash() { assert_eq!( merkle_hash, MerkleHash([ - 207, 29, 184, 163, 158, 22, 137, 73, 72, 58, 24, 246, 67, 9, 44, 20, 32, 22, 86, 206, - 191, 5, 52, 241, 41, 113, 198, 85, 11, 53, 190, 57 + 79, 126, 186, 90, 12, 111, 100, 8, 120, 150, 225, 176, 200, 201, 125, 150, 58, 122, + 214, 216, 68, 6, 125, 247, 248, 4, 165, 185, 157, 44, 13, 151 ]) ); }