Skip to content

Commit

Permalink
Regenerate bindings and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloMansanet committed Dec 24, 2024
1 parent 8dc7b66 commit 73aa951
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fn token_network_fees(

let bps_fee = match billing_config {
Some(config) if config_for_dest_chain.billing.deci_bps > 0 => {
let token_price = get_validated_token_price(&config)?;
let token_price = get_validated_token_price(config)?;
// Calculate token transfer value, then apply fee ratio
// ratio represents multiples of 0.1bps, or 1e-5
Usd18Decimals(
Expand Down
11 changes: 6 additions & 5 deletions chains/solana/contracts/target/idl/ccip_router.json
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,8 @@
"# Arguments",
"",
"* `ctx` - The context containing the accounts required for setting the token billing configuration.",
"* `_chain_selector` - The chain selector.",
"* `_mint` - The public key of the token mint.",
"* `chain_selector` - The chain selector.",
"* `mint` - The public key of the token mint.",
"* `cfg` - The token billing configuration."
],
"accounts": [
Expand Down Expand Up @@ -994,10 +994,11 @@
"In addition to the fixed amount of accounts defined in the `GetFee` context,",
"the following accounts must be provided:",
"",
"* First, the billing token config accounts for each token sent, starting with the",
"fee token, sequentially.",
"* First, the billing token config accounts for each token sent with the message, sequentially.",
"For each token with no billing config account (i.e. tokens that cannot be possibly used as fee",
"tokens, which also have no BPS fees enabled) the ZERO address must be provided instead.",
"* Then, the per chain / per token config of every token sent with the message, sequentially",
"in the same order, for the destination chain.",
"in the same order.",
"",
"# Returns",
"",
Expand Down
16 changes: 10 additions & 6 deletions chains/solana/contracts/tests/ccip/ccip_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func TestCCIPRouter(t *testing.T) {
// bytes4(keccak256("CCIP ChainFamilySelector EVM"))
ChainFamilySelector: [4]uint8{40, 18, 213, 44},

DefaultTokenFeeUsdcents: 100,
NetworkFeeUsdcents: 100,
DefaultTokenFeeUsdcents: 1,
NetworkFeeUsdcents: 1,
}
// Small enough to fit in u160, big enough to not fall in the precompile space.
validReceiverAddress := [32]byte{}
Expand Down Expand Up @@ -831,7 +831,9 @@ func TestCCIPRouter(t *testing.T) {
// Any nonzero timestamp is valid (for now)
validTimestamp := int64(100)
value := [28]uint8{}
big.NewInt(3e18).FillBytes(value[:])
bigNum, ok := new(big.Int).SetString("1000000000000000000000000000000", 10)
require.True(t, ok)
bigNum.FillBytes(value[:])

testTokens := []TestToken{
{
Expand Down Expand Up @@ -1839,7 +1841,8 @@ func TestCCIPRouter(t *testing.T) {
feeResult := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment)
require.NotNil(t, feeResult)
fee, _ := common.ExtractTypedReturnValue(ctx, feeResult.Meta.LogMessages, config.CcipRouterProgram.String(), binary.LittleEndian.Uint64)
require.Equal(t, uint64(1), fee)
t.Log(fee)
require.Greater(t, fee, uint64(0))
})

t.Run("Fee is retrieved for a correctly formatted message containing a nonnative token", func(t *testing.T) {
Expand Down Expand Up @@ -1873,7 +1876,7 @@ func TestCCIPRouter(t *testing.T) {
feeResult := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment)
require.NotNil(t, feeResult)
fee, _ := common.ExtractTypedReturnValue(ctx, feeResult.Meta.LogMessages, config.CcipRouterProgram.String(), binary.LittleEndian.Uint64)
require.Equal(t, uint64(3), fee)
require.Greater(t, fee, uint64(0))
})

t.Run("Cannot get fee for message with invalid address", func(t *testing.T) {
Expand Down Expand Up @@ -1913,6 +1916,7 @@ func TestCCIPRouter(t *testing.T) {
message := ccip_router.Solana2AnyMessage{
FeeToken: wsol.mint,
Receiver: validReceiverAddress[:],
Data: []byte{4, 5, 6},
}

raw := ccip_router.NewCcipSendInstruction(
Expand Down Expand Up @@ -2722,7 +2726,7 @@ func TestCCIPRouter(t *testing.T) {
feeResult := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{ix}, user, config.DefaultCommitment)
require.NotNil(t, feeResult)
fee, _ := common.ExtractTypedReturnValue(ctx, feeResult.Meta.LogMessages, config.CcipRouterProgram.String(), binary.LittleEndian.Uint64)
require.Equal(t, uint64(1), fee)
require.Greater(t, fee, uint64(0))

initialBalance := getBalance(token.billingATA)

Expand Down
7 changes: 4 additions & 3 deletions chains/solana/gobindings/ccip_router/GetFee.go

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

4 changes: 2 additions & 2 deletions chains/solana/gobindings/ccip_router/SetTokenBilling.go

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

11 changes: 6 additions & 5 deletions chains/solana/gobindings/ccip_router/instructions.go

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

0 comments on commit 73aa951

Please sign in to comment.