From a3a9cace2b218f2920926ddc351b63ac115a2870 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 20 Aug 2024 15:43:12 +0200 Subject: [PATCH] fix some test failures, hex encode u128,u256 in SATN format --- .../core/src/db/datastore/locking_tx_datastore/datastore.rs | 6 +++--- crates/core/src/sql/compiler.rs | 2 +- crates/sats/src/satn.rs | 4 ++-- crates/standalone/src/control_db.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/core/src/db/datastore/locking_tx_datastore/datastore.rs b/crates/core/src/db/datastore/locking_tx_datastore/datastore.rs index 9000f830c80..26a023d55da 100644 --- a/crates/core/src/db/datastore/locking_tx_datastore/datastore.rs +++ b/crates/core/src/db/datastore/locking_tx_datastore/datastore.rs @@ -1353,12 +1353,12 @@ mod tests { ColRow { table: ST_CONSTRAINT_ID.into(), pos: 4, name: "columns", ty: AlgebraicType::array(ColId::get_type()) }, ColRow { table: ST_MODULE_ID.into(), pos: 0, name: "database_address", ty: AlgebraicType::U128 }, - ColRow { table: ST_MODULE_ID.into(), pos: 1, name: "owner_identity", ty: AlgebraicType::bytes() }, + ColRow { table: ST_MODULE_ID.into(), pos: 1, name: "owner_identity", ty: AlgebraicType::U256 }, ColRow { table: ST_MODULE_ID.into(), pos: 2, name: "program_kind", ty: AlgebraicType::U8 }, - ColRow { table: ST_MODULE_ID.into(), pos: 3, name: "program_hash", ty: AlgebraicType::bytes() }, + ColRow { table: ST_MODULE_ID.into(), pos: 3, name: "program_hash", ty: AlgebraicType::U256 }, ColRow { table: ST_MODULE_ID.into(), pos: 4, name: "program_bytes", ty: AlgebraicType::bytes() }, - ColRow { table: ST_CLIENT_ID.into(), pos: 0, name: "identity", ty: AlgebraicType::bytes()}, + ColRow { table: ST_CLIENT_ID.into(), pos: 0, name: "identity", ty: AlgebraicType::U256}, ColRow { table: ST_CLIENT_ID.into(), pos: 1, name: "address", ty: AlgebraicType::U128}, ColRow { table: ST_VAR_ID.into(), pos: 0, name: "name", ty: AlgebraicType::String }, diff --git a/crates/core/src/sql/compiler.rs b/crates/core/src/sql/compiler.rs index dc21411684d..3cff6d43d2e 100644 --- a/crates/core/src/sql/compiler.rs +++ b/crates/core/src/sql/compiler.rs @@ -412,7 +412,7 @@ mod tests { // Check tuples let kind = [ ("a", AlgebraicType::String), - ("b", AlgebraicType::bytes()), + ("b", AlgebraicType::U256), ("o", Identity::get_type()), ("p", Address::get_type()), ] diff --git a/crates/sats/src/satn.rs b/crates/sats/src/satn.rs index 9e9605e5a1d..7607f4c6e27 100644 --- a/crates/sats/src/satn.rs +++ b/crates/sats/src/satn.rs @@ -273,10 +273,10 @@ impl<'a, 'b> ser::Serializer for SatnFormatter<'a, 'b> { write!(self, "{v}") } fn serialize_u128(mut self, v: u128) -> Result { - write!(self, "{v}") + write!(self, "0x{}", hex::encode(v.to_le_bytes())) } fn serialize_u256(mut self, v: u256) -> Result { - write!(self, "{v}") + write!(self, "0x{}", hex::encode(v.to_le_bytes())) } fn serialize_i8(mut self, v: i8) -> Result { write!(self, "{v}") diff --git a/crates/standalone/src/control_db.rs b/crates/standalone/src/control_db.rs index 92a2c1f1b21..d00791af9dd 100644 --- a/crates/standalone/src/control_db.rs +++ b/crates/standalone/src/control_db.rs @@ -259,7 +259,7 @@ impl ControlDb { let name = b"clockworklabs:"; let bytes = [name, bytes].concat(); let hash = hash_bytes(bytes); - let address = Address::from_slice(&hash.abbreviate()); + let address = Address::from_slice(hash.abbreviate()); Ok(address) }