Skip to content

Commit

Permalink
Add serialization compatibility test for transaction index
Browse files Browse the repository at this point in the history
  • Loading branch information
jbearer committed Jul 3, 2024
1 parent 8c25dad commit f11458f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Binary file added data/tx_index.bin
Binary file not shown.
4 changes: 4 additions & 0 deletions data/tx_index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"ns_index": [0, 0, 0, 0],
"tx_index": [0, 0, 0, 0]
}
13 changes: 12 additions & 1 deletion sequencer/src/reference_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
use crate::{
block::NsTable, state::FeeInfo, ChainConfig, FeeAccount, Header, L1BlockInfo, Payload,
Transaction, ValidatedState,
SeqTypes, Transaction, ValidatedState,
};
use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use committable::Committable;
use es_version::SequencerVersion;
use hotshot_query_service::availability::QueryablePayload;
use hotshot_types::traits::{
block_contents::vid_commitment, signature_key::BuilderSignatureKey, BlockPayload, EncodeBytes,
};
Expand Down Expand Up @@ -135,6 +136,11 @@ fn reference_transaction() -> Transaction {

const REFERENCE_TRANSACTION_COMMITMENT: &str = "TX~jmYCutMVgguprgpZHywPwkehwXfibQx951gh4LSLmfwp";

async fn reference_tx_index() -> <Payload as QueryablePayload<SeqTypes>>::TransactionIndex {
let payload = reference_payload().await;
payload.iter(payload.ns_table()).next().unwrap()
}

fn reference_test_without_committable<T: Serialize + DeserializeOwned + Eq + Debug>(
name: &str,
reference: &T,
Expand Down Expand Up @@ -256,6 +262,11 @@ async fn test_reference_payload() {
reference_test_without_committable("payload", &reference_payload().await);
}

#[async_std::test]
async fn test_reference_tx_index() {
reference_test_without_committable("tx_index", &reference_tx_index().await);
}

#[async_std::test]
async fn test_reference_ns_table() {
reference_test(
Expand Down

0 comments on commit f11458f

Please sign in to comment.