Skip to content

Commit

Permalink
fix constants
Browse files Browse the repository at this point in the history
  • Loading branch information
greged93 committed Sep 21, 2023
1 parent 18e78ca commit 41c994b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
1 change: 1 addition & 0 deletions crates/sequencer/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod test_constants {
pub static ref SEQUENCER_ADDRESS: ContractAddress = ContractAddress(TryInto::<PatriciaKey>::try_into(StarkFelt::from(1234u16)).unwrap());
pub static ref FEE_TOKEN_ADDRESS: ContractAddress = ContractAddress(TryInto::<PatriciaKey>::try_into(StarkFelt::from(12345u16)).unwrap());

pub static ref ZERO_FELT: StarkFelt = StarkFelt::from(0u8);
pub static ref ONE_FELT: StarkFelt = StarkFelt::from(1u8);
pub static ref TWO_FELT: StarkFelt = StarkFelt::from(2u8);
pub static ref ONE_PATRICIA: PatriciaKey = TryInto::<PatriciaKey>::try_into(*ONE_FELT).unwrap();
Expand Down
56 changes: 30 additions & 26 deletions crates/sequencer/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,21 @@ mod tests {
use blockifier::abi::abi_utils::get_storage_var_address;
use blockifier::execution::contract_class::{ContractClass, ContractClassV0};
use blockifier::state::state_api::State as BlockifierState;
use starknet::core::types::{
BroadcastedInvokeTransaction, BroadcastedTransaction, FieldElement,
};
use starknet_api::core::{ChainId, ClassHash, ContractAddress};
use blockifier::transaction::account_transaction::AccountTransaction;
use starknet::core::types::FieldElement;
use starknet_api::core::{ChainId, ClassHash, ContractAddress, Nonce};
use starknet_api::hash::StarkFelt;
use starknet_api::transaction::{
Calldata, Fee, InvokeTransaction, InvokeTransactionV1, TransactionHash,
TransactionSignature,
};

use crate::constants::test_constants::{
FEE_TOKEN_ADDRESS, ONE_BLOCK_NUMBER, ONE_BLOCK_TIMESTAMP, ONE_CLASS_HASH, SENDER_ADDRESS,
FEE_TOKEN_ADDRESS, ONE_BLOCK_NUMBER, ONE_BLOCK_TIMESTAMP, ONE_CLASS_HASH,
SEQUENCER_ADDRESS, TEST_ADDRESS, TEST_CONTRACT_ACCOUNT, TEST_CONTRACT_ADDRESS,
TWO_CLASS_HASH,
TWO_CLASS_HASH, ZERO_FELT,
};
use crate::state::State;
use crate::transaction::StarknetTransaction;

use super::*;

Expand Down Expand Up @@ -170,25 +172,27 @@ mod tests {
let mut sequencer = Sequencer::new(context, state);

// When
let transaction = StarknetTransaction::new(BroadcastedTransaction::Invoke(
BroadcastedInvokeTransaction {
sender_address: *SENDER_ADDRESS,
calldata: vec![
FieldElement::ONE,
FieldElement::from_hex_be(
"0x3b82f69851fa1625b367ea6c116252a84257da483dcec4d4e4bc270eb5c70a7",
)
.unwrap(),
FieldElement::ZERO,
],
max_fee: FieldElement::from(1_000_000u32),
signature: vec![],
nonce: FieldElement::ZERO,
is_query: false,
},
))
.try_into()
.unwrap();
let transaction = Transaction::AccountTransaction(AccountTransaction::Invoke(
InvokeTransaction::V1(InvokeTransactionV1 {
transaction_hash: TransactionHash(*ZERO_FELT),
sender_address: *TEST_CONTRACT_ACCOUNT,
calldata: Calldata(
vec![
*TEST_ADDRESS, // destination
FieldElement::from_hex_be(
"0x3b82f69851fa1625b367ea6c116252a84257da483dcec4d4e4bc270eb5c70a7",
) // selector (inc)
.unwrap()
.into(),
*ZERO_FELT, // no data
]
.into(),
),
max_fee: Fee(1_000_000),
signature: TransactionSignature(vec![]),
nonce: Nonce(*ZERO_FELT),
}),
));
sequencer.execute(transaction).unwrap();

// Then
Expand Down

0 comments on commit 41c994b

Please sign in to comment.