Skip to content

Commit

Permalink
Fix CR interface tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Feb 10, 2025
1 parent a9c0e7c commit a192790
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 126 deletions.
92 changes: 8 additions & 84 deletions contracts/generated/contract_reader_interface/Initialize.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions contracts/generated/contract_reader_interface/instructions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 26 additions & 26 deletions contracts/programs/contract-reader-interface/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anchor_lang::prelude::*;
use std::mem::size_of;
use solana_program::pubkey;
use std::mem::size_of;

declare_id!("6AfuXF6HapDUhQfE4nQG9C1SGtA1YjP3icaJyRfU4RyE");

Expand All @@ -15,6 +15,10 @@ pub mod contract_reader_interface {
account.idx = test_idx;
account.bump = ctx.bumps.data;

Ok(())
}

pub fn initializeOnce(ctx: Context<InitializeOnce>) -> Result<()> {
let multi_read1 = &mut ctx.accounts.multi_read1;
multi_read1.a = 1;
multi_read1.b = 2;
Expand All @@ -24,13 +28,13 @@ pub mod contract_reader_interface {
multi_read2.u = "Hello".to_string();
multi_read2.v = true;
multi_read2.w = [123, 456];

let config1 = &mut ctx.accounts.config_wrapper_account1;
config1.config.usd_per_token = TimestampedPackedU224 {
value: STATIC_VALUE1,
timestamp: STATIC_TIMESTAMP1,
};

let config2 = &mut ctx.accounts.config_wrapper_account2;
config2.config.usd_per_token = TimestampedPackedU224 {
value: STATIC_VALUE2,
Expand Down Expand Up @@ -88,6 +92,14 @@ pub struct Initialize<'info> {
bump)]
pub data: Account<'info, DataAccount>,

pub system_program: Program<'info, System>,
}

#[derive(Accounts)]
pub struct InitializeOnce<'info> {
#[account(mut)]
pub signer: Signer<'info>,

#[account(
init_if_needed,
payer = signer,
Expand All @@ -103,29 +115,27 @@ pub struct Initialize<'info> {
seeds = [b"multi_read2"],
bump)]
pub multi_read2: Account<'info, MultiRead2>,

#[account(
init_if_needed,
payer = signer,
space = 8 + size_of::<BillingTokenConfigWrapper>(),
space = size_of::<BillingTokenConfigWrapper>() + 8,
seeds = [
b"fee_billing_token_config",
ADDRESS_1.as_ref()
],
bump
)]
bump)]
pub config_wrapper_account1: Account<'info, BillingTokenConfigWrapper>,

#[account(
init_if_needed,
payer = signer,
space = 8 + size_of::<BillingTokenConfigWrapper>(),
space = size_of::<BillingTokenConfigWrapper>() + 8,
seeds = [
b"fee_billing_token_config",
ADDRESS_2.as_ref()
],
bump
)]
bump)]
pub config_wrapper_account2: Account<'info, BillingTokenConfigWrapper>,

pub system_program: Program<'info, System>,
Expand Down Expand Up @@ -279,24 +289,14 @@ pub const ADDRESS_1: Pubkey = pubkey!("4RzYhbqRjaZHMnfxiPNDVzuimBbAb2FZErQKCLYKr
pub const ADDRESS_2: Pubkey = pubkey!("9mBYSvyF8RBWNdat6SkZE5ipW5gMrBYqZnTShMsnfsub");

pub const STATIC_VALUE1: [u8; 28] = [
0x00, 0x11, 0x22, 0x33,
0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xAA, 0xBB,
0xCC, 0xDD, 0xEE, 0xFF,
0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
];
pub const STATIC_TIMESTAMP1: i64 = 1_700_000_001;
pub const STATIC_TIMESTAMP1: i64 = 1_700_000_001;

pub const STATIC_VALUE2: [u8; 28] = [
0xAA, 0xBB, 0xCC, 0xDD,
0xEE, 0xFF, 0x11, 0x22,
0x33, 0x44, 0x55, 0x66,
0x77, 0x88, 0x99, 0x00,
0x10, 0x20, 0x30, 0x40,
0x50, 0x60, 0x70, 0x80,
0x90, 0xA0, 0xB0, 0xC0
0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0,
];
pub const STATIC_TIMESTAMP2: i64 = 1_800_000_002;

Expand All @@ -319,5 +319,5 @@ pub struct BillingTokenConfig {
#[derive(InitSpace, Clone, AnchorSerialize, AnchorDeserialize, Debug)]
pub struct TimestampedPackedU224 {
pub value: [u8; 28],
pub timestamp: i64,
pub timestamp: i64,
}
Loading

0 comments on commit a192790

Please sign in to comment.