Skip to content

Commit

Permalink
Removed write_test and moved logic to contract_reader_interface test …
Browse files Browse the repository at this point in the history
…program
  • Loading branch information
silaslenihan committed Dec 12, 2024
1 parent 4ea7b25 commit a996080
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 226 deletions.
3 changes: 1 addition & 2 deletions contracts/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ access_controller = "9xi644bRR8birboDGdTiwBq3C7VEeR7VuamRYYXCubUW"
contract-reader-interface = "6AfuXF6HapDUhQfE4nQG9C1SGtA1YjP3icaJyRfU4RyE"
log-read-test = "J1zQwrBNBngz26jRPNWsUSZMHJwBwpkoDitXRV95LdK4"
ocr_2 = "cjg3oHmg9uuPsP8D6g29NWvhySJkdYdAo9D25PRbKXJ" # need to rename the idl to satisfy anchor.js...
store = "HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny"
write_test = "39vbQVpEMtZtg3e6ZSE7nBSzmNZptmW45WnLkbqEe4TU"
store = "HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny"
7 changes: 0 additions & 7 deletions contracts/Cargo.lock

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

41 changes: 41 additions & 0 deletions contracts/programs/contract-reader-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ pub mod contract_reader_interface {

Ok(())
}

pub fn initialize_lookup_table(
ctx: Context<InitializeLookupTableData>,
lookup_table: Pubkey,
) -> Result<()> {
let account = &mut ctx.accounts.write_data_account;
account.version = 1;
account.administrator = ctx.accounts.admin.key();
account.pending_administrator = Pubkey::default();
account.lookup_table = lookup_table;

Ok(())
}
}

#[derive(Accounts)]
Expand All @@ -37,6 +50,34 @@ pub struct Initialize<'info> {
pub system_program: Program<'info, System>,
}

#[derive(Accounts)]
pub struct InitializeLookupTableData<'info> {
/// PDA for LookupTableDataAccount, derived from seeds and created by the System Program
#[account(
init,
payer = admin,
space = size_of::<LookupTableDataAccount>() + 8,
seeds = [b"data"],
bump
)]
pub write_data_account: Account<'info, LookupTableDataAccount>,

/// Admin account that pays for PDA creation and signs the transaction
#[account(mut)]
pub admin: Signer<'info>,

/// System Program required for PDA creation
pub system_program: Program<'info, System>,
}

#[account]
pub struct LookupTableDataAccount {
pub version: u8, // Version of the data account
pub administrator: Pubkey, // Administrator public key
pub pending_administrator: Pubkey, // Pending administrator public key
pub lookup_table: Pubkey, // Address of the lookup table
}

#[account]
pub struct DataAccount {
pub idx: u64,
Expand Down
19 changes: 0 additions & 19 deletions contracts/programs/write_test/Cargo.toml

This file was deleted.

2 changes: 0 additions & 2 deletions contracts/programs/write_test/Xargo.toml

This file was deleted.

51 changes: 0 additions & 51 deletions contracts/programs/write_test/src/lib.rs

This file was deleted.

92 changes: 0 additions & 92 deletions gotest.log

This file was deleted.

29 changes: 3 additions & 26 deletions integration-tests/relayinterface/chain_components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
"github.com/smartcontractkit/chainlink-solana/integration-tests/solclient"
"github.com/smartcontractkit/chainlink-solana/integration-tests/utils"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/chainreader"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/client"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
solanautils "github.com/smartcontractkit/chainlink-solana/pkg/solana/utils"
)

func TestChainComponents(t *testing.T) {
Expand Down Expand Up @@ -233,13 +233,13 @@ func (h *helper) Init(t *testing.T) {
privateKey, err := solana.PrivateKeyFromBase58(solclient.DefaultPrivateKeysSolValidator[1])
require.NoError(t, err)

h.rpcURL, h.wsURL = setupTestValidator(t, privateKey.PublicKey().String())
h.rpcURL, h.wsURL = solanautils.SetupTestValidatorWithAnchorPrograms(t, privateKey.PublicKey().String(), []string{"contract-reader-interface"})
h.wsClient, err = ws.Connect(tests.Context(t), h.wsURL)
h.rpcClient = rpc.New(h.rpcURL)

require.NoError(t, err)

client.FundTestAccounts(t, []solana.PublicKey{privateKey.PublicKey()}, h.rpcURL)
solanautils.FundAccounts(t, tests.Context(t), []solana.PrivateKey{privateKey}, h.rpcClient)

pubkey, err := solana.PublicKeyFromBase58(programPubKey)
require.NoError(t, err)
Expand Down Expand Up @@ -380,26 +380,3 @@ func (h *helper) waitForTX(t *testing.T, sig solana.Signature, commitment rpc.Co
}

const programPubKey = "6AfuXF6HapDUhQfE4nQG9C1SGtA1YjP3icaJyRfU4RyE"

// upgradeAuthority is admin solana.PrivateKey as string
func setupTestValidator(t *testing.T, upgradeAuthority string) (string, string) {
t.Helper()

soPath := filepath.Join(utils.ContractsDir, "contract_reader_interface.so")

_, err := os.Stat(soPath)
if err != nil {
t.Log(err.Error())
t.FailNow()
}

flags := []string{
"--warp-slot", "42",
"--upgradeable-program",
programPubKey,
soPath,
upgradeAuthority,
}

return client.SetupLocalSolNodeWithFlags(t, flags...)
}
Loading

0 comments on commit a996080

Please sign in to comment.