Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit aa5fdee

Browse files
authored
Refactor test_create_program_governance (#3637)
* Splits the unrealistically large transaction generated by with_governed_program() into many. * Update apt packet list before attempting install in CI.
1 parent dad3fba commit aa5fdee

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

ci/install-build-deps.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
set -ex
44

5+
sudo apt update
56
sudo apt install libudev-dev -y
67
sudo apt install binutils-dev -y
78
sudo apt install libunwind-dev -y

governance/program/tests/program_test/mod.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ impl GovernanceProgramTest {
15371537
program_data.len(),
15381538
));
15391539

1540-
let mut instructions = bpf_loader_upgradeable::create_buffer(
1540+
let instructions = bpf_loader_upgradeable::create_buffer(
15411541
&self.bench.payer.pubkey(),
15421542
&program_buffer_keypair.pubkey(),
15431543
&program_upgrade_authority_keypair.pubkey(),
@@ -1546,15 +1546,23 @@ impl GovernanceProgramTest {
15461546
)
15471547
.unwrap();
15481548

1549-
let chunk_size = 800;
1549+
self.bench
1550+
.process_transaction(&instructions, Some(&[&program_buffer_keypair]))
1551+
.await
1552+
.unwrap();
15501553

1551-
for (chunk, i) in program_data.chunks(chunk_size).zip(0..) {
1552-
instructions.push(bpf_loader_upgradeable::write(
1554+
const CHUNK_SIZE: usize = 800;
1555+
for (i, chunk) in program_data.chunks(CHUNK_SIZE).enumerate() {
1556+
let instruction = bpf_loader_upgradeable::write(
15531557
&program_buffer_keypair.pubkey(),
15541558
&program_upgrade_authority_keypair.pubkey(),
1555-
(i * chunk_size) as u32,
1559+
(i * CHUNK_SIZE) as u32,
15561560
chunk.to_vec(),
1557-
));
1561+
);
1562+
self.bench
1563+
.process_transaction(&[instruction], Some(&[&program_upgrade_authority_keypair]))
1564+
.await
1565+
.unwrap();
15581566
}
15591567

15601568
let program_account_rent = self
@@ -1572,16 +1580,10 @@ impl GovernanceProgramTest {
15721580
)
15731581
.unwrap();
15741582

1575-
instructions.extend_from_slice(&deploy_ixs);
1576-
15771583
self.bench
15781584
.process_transaction(
1579-
&instructions[..],
1580-
Some(&[
1581-
&program_upgrade_authority_keypair,
1582-
&program_keypair,
1583-
&program_buffer_keypair,
1584-
]),
1585+
&deploy_ixs,
1586+
Some(&[&program_upgrade_authority_keypair, &program_keypair]),
15851587
)
15861588
.await
15871589
.unwrap();

0 commit comments

Comments
 (0)