diff --git a/src/state.cairo b/src/state.cairo index eb9c1950..37b072ff 100644 --- a/src/state.cairo +++ b/src/state.cairo @@ -13,7 +13,7 @@ pub struct ChainState { pub epoch_start_time: u32, /// Previous timestamps. pub prev_timestamps: Span, - // TODO: utreexo_roots? +// TODO: utreexo_roots? } /// Represents a block in the blockchain. @@ -65,9 +65,9 @@ pub struct Transaction { #[derive(Drop, Copy)] pub struct TxOut { /// The value of the output. - pub value: i64, + value: i64, /// The public key script of the output. - pub pk_script: @ByteArray, + pk_script: @ByteArray, } /// Input of a transaction. @@ -75,12 +75,12 @@ pub struct TxOut { #[derive(Drop, Copy)] pub struct TxIn { /// The transaction ID of the input. - pub txid: u256, + txid: u256, /// The index of the input. - pub index: u32, + index: u32, /// The script of the input. - pub script: @ByteArray, + script: @ByteArray, /// The sequence of the input. - pub sequence: u32, + sequence: u32, } diff --git a/src/validation.cairo b/src/validation.cairo index 06e626d3..478c8e71 100644 --- a/src/validation.cairo +++ b/src/validation.cairo @@ -71,7 +71,7 @@ fn validate_merkle_root(self: @ChainState, block: @Block) -> Result<(), ByteArra mod tests { use core::result::ResultTrait; use super::validate_target; - use super::{Block, ChainState,}; + use super::{Block, ChainState}; use super::super::state::{Header, Transaction, TxIn, TxOut}; use core::array::{Span}; @@ -85,15 +85,13 @@ mod tests { epoch_start_time: 1, prev_timestamps: array![1, 2, 3, 4, 5].span(), }; - let txIn = TxIn { txid: 1, index: 1, script: @"1", sequence: 1, }; - let txOut = TxOut { value: 1, pk_script: @"1", }; - let transaction = Transaction { - version: 1, inputs: array![txIn].span(), outputs: array![txOut].span(), lock_time: 1, + let mut block = Block { + header: Header { + version: 1, prev_block_hash: 1, merkle_root_hash: 1, time: 1, bits: 1, nonce: 1, + }, + txs: ArrayTrait::new().span(), }; - let header = Header { - version: 1, prev_block_hash: 1, merkle_root_hash: 1, time: 1, bits: 1, nonce: 1, - }; - let mut block = Block { header: header, txs: array![transaction].span() }; + let result = validate_target(@chain_state, @block); assert(result.is_ok(), 'Expected target to be valid');