Skip to content

Commit

Permalink
Slight improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
syan095 committed Nov 13, 2024
1 parent dd365cf commit 0e7e200
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 5 additions & 8 deletions state-chain/cf-integration-tests/src/solana.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,20 +880,17 @@ fn solana_can_recycle_deposit_channels() {
}
) => (deposit_address, channel_id, source_chain_expiry_block)
);
let deposit_address = match channel_address {
EncodedAddress::Sol(address) => Some(SolAddress(address)),
_ => None
}.expect("Deposit channel generated must be on the Solana Chain");
let deposit_address = channel_address.try_into().expect("Deposit channel generated must be on the Solana Chain");

assert!(pallet_cf_ingress_egress::DepositChannelLookup::<Runtime, SolanaInstance>::contains_key(deposit_address));

// Generated deposit channel address should be correct.
let (generated_sol_address, generated_sol_bump) = <AddressDerivation as AddressDerivationApi<Solana>>::generate_address_and_state(
let (generated_address, generated_bump) = <AddressDerivation as AddressDerivationApi<Solana>>::generate_address_and_state(
SOL_SOL,
channel_id,
)
.expect("Must be able to derive Solana deposit channel.");
assert_eq!(deposit_address, generated_sol_address);
assert_eq!(deposit_address, generated_address);

// Witness Solana ingress in the deposit channel
testnet.move_forward_blocks(10);
Expand All @@ -917,7 +914,7 @@ fn solana_can_recycle_deposit_channels() {
channel_id,
address: deposit_address,
asset: SOL_SOL,
state: generated_sol_bump,
state: generated_bump,
})
);

Expand Down Expand Up @@ -960,7 +957,7 @@ fn solana_can_recycle_deposit_channels() {
channel_id,
address: deposit_address,
asset: SOL_USDC,
state: generated_sol_bump,
state: generated_bump,
})
);
});
Expand Down
10 changes: 10 additions & 0 deletions state-chain/chains/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ impl TryFrom<ForeignChainAddress> for ScriptPubkey {
}
}

impl TryFrom<EncodedAddress> for SolAddress {
type Error = AddressError;

fn try_from(address: EncodedAddress) -> Result<Self, Self::Error> {
match address {
EncodedAddress::Sol(addr) => Ok(addr.into()),
_ => Err(AddressError::InvalidAddress),
}
}
}
pub trait IntoForeignChainAddress<C: Chain> {
fn into_foreign_chain_address(address: C::ChainAccount) -> ForeignChainAddress;
}
Expand Down

0 comments on commit 0e7e200

Please sign in to comment.