Skip to content

Commit

Permalink
fix: redundant reg table
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Jan 15, 2025
1 parent 69ab92a commit 0549a1a
Showing 1 changed file with 30 additions and 49 deletions.
79 changes: 30 additions & 49 deletions crates/compression/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ mod tests {
height: u32,
consensus_parameters_version: u32,
state_transition_bytecode_version: u32,
registration_inputs: Vec<(RegistryKeyspace, RegistryKey, [u8; 32])>,
registrations: RegistrationsPerTable,
}

fn postcard_roundtrip_strategy() -> impl Strategy<Value = PostcardRoundtripStrategy> {
Expand Down Expand Up @@ -148,13 +148,39 @@ mod tests {
state_transition_bytecode_version,
registration_inputs,
)| {
let mut registrations: RegistrationsPerTable = Default::default();
for (ks, key, arr) in registration_inputs {
let value_len_limit = (key.as_u32() % 32) as usize;
match ks {
RegistryKeyspace::Address => {
registrations.address.push((key, arr.into()));
}
RegistryKeyspace::AssetId => {
registrations.asset_id.push((key, arr.into()));
}
RegistryKeyspace::ContractId => {
registrations.contract_id.push((key, arr.into()));
}
RegistryKeyspace::ScriptCode => {
registrations
.script_code
.push((key, arr[..value_len_limit].to_vec().into()));
}
RegistryKeyspace::PredicateCode => {
registrations
.predicate_code
.push((key, arr[..value_len_limit].to_vec().into()));
}
}
}

PostcardRoundtripStrategy {
da_height,
prev_root,
height,
consensus_parameters_version,
state_transition_bytecode_version,
registration_inputs,
registrations,
}
},
)
Expand All @@ -171,32 +197,9 @@ mod tests {
height,
consensus_parameters_version,
state_transition_bytecode_version,
registration_inputs,
registrations,
} = strategy;


let mut registrations: RegistrationsPerTable = Default::default();
for (ks, key, arr) in registration_inputs {
let value_len_limit = (key.as_u32() % 32) as usize;
match ks {
RegistryKeyspace::Address => {
registrations.address.push((key, arr.into()));
}
RegistryKeyspace::AssetId => {
registrations.asset_id.push((key, arr.into()));
}
RegistryKeyspace::ContractId => {
registrations.contract_id.push((key, arr.into()));
}
RegistryKeyspace::ScriptCode => {
registrations.script_code.push((key, arr[..value_len_limit].to_vec().into()));
}
RegistryKeyspace::PredicateCode => {
registrations.predicate_code.push((key, arr[..value_len_limit].to_vec().into()));
}
}
}

let header = PartialBlockHeader {
application: ApplicationHeader {
da_height: da_height.into(),
Expand Down Expand Up @@ -254,31 +257,9 @@ mod tests {
height,
consensus_parameters_version,
state_transition_bytecode_version,
registration_inputs,
registrations,
} = strategy;

let mut registrations: RegistrationsPerTable = Default::default();
for (ks, key, arr) in registration_inputs {
let value_len_limit = (key.as_u32() % 32) as usize;
match ks {
RegistryKeyspace::Address => {
registrations.address.push((key, arr.into()));
}
RegistryKeyspace::AssetId => {
registrations.asset_id.push((key, arr.into()));
}
RegistryKeyspace::ContractId => {
registrations.contract_id.push((key, arr.into()));
}
RegistryKeyspace::ScriptCode => {
registrations.script_code.push((key, arr[..value_len_limit].to_vec().into()));
}
RegistryKeyspace::PredicateCode => {
registrations.predicate_code.push((key, arr[..value_len_limit].to_vec().into()));
}
}
}

let header = CompressedBlockHeader {
application: ApplicationHeader {
da_height: da_height.into(),
Expand Down

0 comments on commit 0549a1a

Please sign in to comment.