Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Refactor test_create_program_governance (#3637)
Browse files Browse the repository at this point in the history
* Splits the unrealistically large transaction generated by with_governed_program() into many.

* Update apt packet list before attempting install in CI.
  • Loading branch information
Lichtso authored Sep 23, 2022
1 parent dad3fba commit aa5fdee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions ci/install-build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -ex

sudo apt update
sudo apt install libudev-dev -y
sudo apt install binutils-dev -y
sudo apt install libunwind-dev -y
30 changes: 16 additions & 14 deletions governance/program/tests/program_test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ impl GovernanceProgramTest {
program_data.len(),
));

let mut instructions = bpf_loader_upgradeable::create_buffer(
let instructions = bpf_loader_upgradeable::create_buffer(
&self.bench.payer.pubkey(),
&program_buffer_keypair.pubkey(),
&program_upgrade_authority_keypair.pubkey(),
Expand All @@ -1546,15 +1546,23 @@ impl GovernanceProgramTest {
)
.unwrap();

let chunk_size = 800;
self.bench
.process_transaction(&instructions, Some(&[&program_buffer_keypair]))
.await
.unwrap();

for (chunk, i) in program_data.chunks(chunk_size).zip(0..) {
instructions.push(bpf_loader_upgradeable::write(
const CHUNK_SIZE: usize = 800;
for (i, chunk) in program_data.chunks(CHUNK_SIZE).enumerate() {
let instruction = bpf_loader_upgradeable::write(
&program_buffer_keypair.pubkey(),
&program_upgrade_authority_keypair.pubkey(),
(i * chunk_size) as u32,
(i * CHUNK_SIZE) as u32,
chunk.to_vec(),
));
);
self.bench
.process_transaction(&[instruction], Some(&[&program_upgrade_authority_keypair]))
.await
.unwrap();
}

let program_account_rent = self
Expand All @@ -1572,16 +1580,10 @@ impl GovernanceProgramTest {
)
.unwrap();

instructions.extend_from_slice(&deploy_ixs);

self.bench
.process_transaction(
&instructions[..],
Some(&[
&program_upgrade_authority_keypair,
&program_keypair,
&program_buffer_keypair,
]),
&deploy_ixs,
Some(&[&program_upgrade_authority_keypair, &program_keypair]),
)
.await
.unwrap();
Expand Down

0 comments on commit aa5fdee

Please sign in to comment.