Skip to content

Commit 25dae62

Browse files
authored
Merge pull request #453 from input-output-hk/lowhung/fix-tests-for-utxo-reversion
Fix failing tests due to UTxOIdentifier change
2 parents 93e3b9b + dee59fb commit 25dae62

File tree

33 files changed

+676
-156
lines changed

33 files changed

+676
-156
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ restore.sh
44
startup.sh
55
configuration/
66
docker-compose.yaml
7+
.DS_Store
78

89
# Nix
910
result
@@ -13,3 +14,6 @@ result-*
1314
.direnv/
1415
.envrc.local
1516
tests/fixtures/134092758.670ca68c3de580f8469677754a725e86ca72a7be381d3108569f0704a5fca327.cbor
17+
18+
downloads/
19+
fjall-*/

Cargo.lock

Lines changed: 33 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/src/queries/blocks.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use crate::queries::errors::QueryError;
22
use crate::{
33
queries::misc::Order,
44
serialization::{Bech32Conversion, Bech32WithHrp},
5-
Address, BlockHash, GenesisDelegate, HeavyDelegate, KeyHash, TxHash, TxIdentifier,
6-
VrfKeyHash,
5+
Address, BlockHash, GenesisDelegate, HeavyDelegate, KeyHash, TxHash, TxIdentifier, VrfKeyHash,
76
};
87
use cryptoxide::hashing::blake2b::Blake2b;
98
use serde::ser::{Serialize, SerializeStruct, Serializer};

common/src/types.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,12 +2410,18 @@ mod tests {
24102410

24112411
#[test]
24122412
fn test_utxo_identifier_to_bytes() -> Result<()> {
2413-
let tx_hash = TxHash::try_from(hex::decode("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f").unwrap()).unwrap();
2413+
let tx_hash = TxHash::try_from(
2414+
hex::decode("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
2415+
.unwrap(),
2416+
)
2417+
.unwrap();
24142418
let output_index = 42;
24152419
let utxo = UTxOIdentifier::new(tx_hash, output_index);
24162420
let bytes = utxo.to_bytes();
2417-
assert_eq!(hex::encode(bytes),
2418-
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f002a");
2421+
assert_eq!(
2422+
hex::encode(bytes),
2423+
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f002a"
2424+
);
24192425

24202426
Ok(())
24212427
}

modules/address_state/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# fjall immutable db
22
fjall-*/
3+
db/

modules/address_state/src/state.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl State {
233233
#[cfg(test)]
234234
mod tests {
235235
use super::*;
236-
use acropolis_common::{Address, AddressDelta, UTxOIdentifier, Value};
236+
use acropolis_common::{Address, AddressDelta, TxHash, UTxOIdentifier, Value};
237237
use tempfile::tempdir;
238238

239239
fn dummy_address() -> Address {
@@ -284,7 +284,7 @@ mod tests {
284284
let mut state = setup_state_and_store().await?;
285285

286286
let addr = dummy_address();
287-
let utxo = UTxOIdentifier::new(0, 0, 0);
287+
let utxo = UTxOIdentifier::new(TxHash::default(), 0);
288288
let tx_id = TxIdentifier::new(0, 0);
289289
let deltas = vec![delta(&addr, tx_id, vec![], vec![utxo], 0, 1)];
290290

@@ -295,7 +295,10 @@ mod tests {
295295
let utxos = state.get_address_utxos(&addr).await?;
296296
assert!(utxos.is_some());
297297
assert_eq!(utxos.as_ref().unwrap().len(), 1);
298-
assert_eq!(utxos.as_ref().unwrap()[0], UTxOIdentifier::new(0, 0, 0));
298+
assert_eq!(
299+
utxos.as_ref().unwrap()[0],
300+
UTxOIdentifier::new(TxHash::default(), 0)
301+
);
299302

300303
// Drain volatile to immutable
301304
state.volatile.epoch_start_block = 1;
@@ -305,7 +308,10 @@ mod tests {
305308
let utxos = state.get_address_utxos(&addr).await?;
306309
assert!(utxos.is_some());
307310
assert_eq!(utxos.as_ref().unwrap().len(), 1);
308-
assert_eq!(utxos.as_ref().unwrap()[0], UTxOIdentifier::new(0, 0, 0));
311+
assert_eq!(
312+
utxos.as_ref().unwrap()[0],
313+
UTxOIdentifier::new(TxHash::default(), 0)
314+
);
309315

310316
// Perisist immutable to disk
311317
state.immutable.persist_epoch(0, &state.config).await?;
@@ -314,7 +320,10 @@ mod tests {
314320
let utxos = state.get_address_utxos(&addr).await?;
315321
assert!(utxos.is_some());
316322
assert_eq!(utxos.as_ref().unwrap().len(), 1);
317-
assert_eq!(utxos.as_ref().unwrap()[0], UTxOIdentifier::new(0, 0, 0));
323+
assert_eq!(
324+
utxos.as_ref().unwrap()[0],
325+
UTxOIdentifier::new(TxHash::default(), 0)
326+
);
318327

319328
Ok(())
320329
}
@@ -326,7 +335,7 @@ mod tests {
326335
let mut state = setup_state_and_store().await?;
327336

328337
let addr = dummy_address();
329-
let utxo = UTxOIdentifier::new(0, 0, 0);
338+
let utxo = UTxOIdentifier::new(TxHash::default(), 0);
330339
let tx_id_create = TxIdentifier::new(0, 0);
331340
let tx_id_spend = TxIdentifier::new(1, 0);
332341

@@ -377,8 +386,8 @@ mod tests {
377386
let mut state = setup_state_and_store().await?;
378387

379388
let addr = dummy_address();
380-
let utxo_old = UTxOIdentifier::new(0, 0, 0);
381-
let utxo_new = UTxOIdentifier::new(0, 1, 0);
389+
let utxo_old = UTxOIdentifier::new(TxHash::default(), 0);
390+
let utxo_new = UTxOIdentifier::new(TxHash::default(), 1);
382391
let tx_id_create_old = TxIdentifier::new(0, 0);
383392
let tx_id_spend_old_create_new = TxIdentifier::new(1, 0);
384393

modules/assets_state/src/state.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,8 @@ mod tests {
690690
};
691691
use acropolis_common::{
692692
Address, AddressDelta, AssetInfoRecord, AssetMetadata, AssetMetadataStandard, AssetName,
693-
Datum, NativeAsset, NativeAssetDelta, PolicyId, ShelleyAddress, TxIdentifier, TxOutput,
694-
TxUTxODeltas, UTxOIdentifier, Value,
693+
Datum, NativeAsset, NativeAssetDelta, PolicyId, ShelleyAddress, TxHash, TxIdentifier,
694+
TxOutput, TxUTxODeltas, UTxOIdentifier, Value,
695695
};
696696
use serde_cbor::Value as CborValue;
697697

@@ -845,7 +845,7 @@ mod tests {
845845

846846
fn make_output(policy_id: PolicyId, asset_name: AssetName, datum: Option<Vec<u8>>) -> TxOutput {
847847
TxOutput {
848-
utxo_identifier: UTxOIdentifier::new(0, 0, 0),
848+
utxo_identifier: UTxOIdentifier::new(TxHash::default(), 0),
849849
address: dummy_address(),
850850
value: Value {
851851
lovelace: 0,
@@ -1263,7 +1263,7 @@ mod tests {
12631263
StoreTransactions::None,
12641264
);
12651265

1266-
let input = UTxOIdentifier::new(0, 0, 0);
1266+
let input = UTxOIdentifier::new(TxHash::default(), 0);
12671267
let output = make_output(policy_id, name, None);
12681268

12691269
let tx_deltas = TxUTxODeltas {
@@ -1428,15 +1428,15 @@ mod tests {
14281428
tx_identifier,
14291429
inputs: Vec::new(),
14301430
outputs: vec![TxOutput {
1431-
utxo_identifier: UTxOIdentifier::new(0, 0, 0),
1431+
utxo_identifier: UTxOIdentifier::new(TxHash::default(), 0),
14321432
..output.clone()
14331433
}],
14341434
};
14351435
let tx2 = TxUTxODeltas {
14361436
tx_identifier,
14371437
inputs: Vec::new(),
14381438
outputs: vec![TxOutput {
1439-
utxo_identifier: UTxOIdentifier::new(0, 0, 1),
1439+
utxo_identifier: UTxOIdentifier::new(TxHash::default(), 1),
14401440
..output
14411441
}],
14421442
};
@@ -1470,15 +1470,15 @@ mod tests {
14701470
tx_identifier: TxIdentifier::new(9, 0),
14711471
inputs: Vec::new(),
14721472
outputs: vec![TxOutput {
1473-
utxo_identifier: UTxOIdentifier::new(9, 0, 0),
1473+
utxo_identifier: UTxOIdentifier::new(TxHash::default(), 0),
14741474
..out1
14751475
}],
14761476
};
14771477
let tx2 = TxUTxODeltas {
14781478
tx_identifier: TxIdentifier::new(10, 0),
14791479
inputs: Vec::new(),
14801480
outputs: vec![TxOutput {
1481-
utxo_identifier: UTxOIdentifier::new(10, 0, 0),
1481+
utxo_identifier: UTxOIdentifier::new(TxHash::default(), 0),
14821482
..out2
14831483
}],
14841484
};
@@ -1513,23 +1513,23 @@ mod tests {
15131513
tx_identifier: TxIdentifier::new(9, 0),
15141514
inputs: Vec::new(),
15151515
outputs: vec![TxOutput {
1516-
utxo_identifier: UTxOIdentifier::new(9, 0, 0),
1516+
utxo_identifier: UTxOIdentifier::new(TxHash::default(), 0),
15171517
..base_output.clone()
15181518
}],
15191519
};
15201520
let tx2 = TxUTxODeltas {
15211521
tx_identifier: TxIdentifier::new(8, 0),
15221522
inputs: Vec::new(),
15231523
outputs: vec![TxOutput {
1524-
utxo_identifier: UTxOIdentifier::new(8, 0, 0),
1524+
utxo_identifier: UTxOIdentifier::new(TxHash::default(), 0),
15251525
..base_output.clone()
15261526
}],
15271527
};
15281528
let tx3 = TxUTxODeltas {
15291529
tx_identifier: TxIdentifier::new(7, 0),
15301530
inputs: Vec::new(),
15311531
outputs: vec![TxOutput {
1532-
utxo_identifier: UTxOIdentifier::new(7, 0, 0),
1532+
utxo_identifier: UTxOIdentifier::new(TxHash::default(), 0),
15331533
..base_output
15341534
}],
15351535
};

modules/chain_store/src/chain_store.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,11 @@ impl ChainStore {
434434
// TODO! Look up TxHash to get block hash, and index of Tx in block
435435
}
436436

437-
Ok(BlocksStateQueryResponse::BlockHashesAndIndexOfTransactionHashes(
438-
block_hashes_and_indexes,
439-
))
437+
Ok(
438+
BlocksStateQueryResponse::BlockHashesAndIndexOfTransactionHashes(
439+
block_hashes_and_indexes,
440+
),
441+
)
440442
}
441443
BlocksStateQuery::GetTransactionHashesAndTimestamps { tx_ids } => {
442444
let mut tx_hashes = Vec::with_capacity(tx_ids.len());
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Acropolis indexer module
22

33
[package]
4-
name = "acropolis_module_indexer"
4+
name = "acropolis_module_custom_indexer"
55
version = "0.1.0"
66
edition = "2021"
77
authors = ["William Hankins <william@sundae.fi>"]
@@ -14,9 +14,13 @@ acropolis_common = { path = "../../common" }
1414
caryatid_sdk = { workspace = true }
1515

1616
anyhow = { workspace = true }
17+
bincode = "1"
1718
config = { workspace = true }
19+
fjall = "2.7.0"
20+
pallas = { workspace = true}
1821
serde = { workspace = true, features = ["rc"] }
22+
tokio = { workspace = true }
1923
tracing = { workspace = true }
2024

2125
[lib]
22-
path = "src/indexer.rs"
26+
path = "src/custom_indexer.rs"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# The topic to publish sync commands on
2+
sync-command-publisher-topic = "cardano.sync.command"
3+
# The topic to receive txs on
4+
txs-subscribe-topic = "cardano.txs"

0 commit comments

Comments
 (0)