Skip to content

Commit

Permalink
Replace buildjet runners (#1162)
Browse files Browse the repository at this point in the history
  • Loading branch information
febo authored Nov 19, 2023
1 parent d49ff0a commit 23789d8
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 292 deletions.
5 changes: 4 additions & 1 deletion .github/actions/program/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ runs:
- uses: actions/checkout@v3

# Build and install deps
- uses: ./.github/actions/program/auction-house
if: ${{ inputs.name == 'auction-house' }}

- uses: ./.github/actions/program/auctioneer
if: ${{ inputs.name == 'auctioneer' }}

Expand All @@ -21,7 +24,7 @@ runs:
- uses: ./.github/actions/program/token-metadata-and-metaplex
if: ${{ inputs.name == 'nft-packs' }}

- name: "Dump token metadata"
- name: 'Dump token metadata'
working-directory: ./${{ inputs.name }}/program
run: |
mkdir -p ../../test-programs
Expand Down
17 changes: 17 additions & 0 deletions .github/actions/program/auction-house/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Implicit dependencies
# - actions/checkout@v3
# - ./.github/actions/install-linux-build-deps
# - ./.github/actions/install-solana
# - ./.github/actions/install-rust

name: Auction House Program Dependencies
description: Builds the dependencies for the Auction House program test
runs:
using: 'composite'
steps:
# Get Token Auth Rules program
- name: Get Token Auth Rules
run: |
mkdir -p test-programs
solana program dump -u https://api.mainnet-beta.solana.com auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg test-programs/mpl_token_auth_rules.so
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/apply-version-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
update-pr-with-changes:
needs: [ get-changes-scope, get-version-scope ]
if: needs.get-version-scope.outputs.has-versioning == 'true' && needs.get-changes-scope.outputs.num-packages > 0
runs-on: buildjet-16vcpu-ubuntu-2204
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-linux-build-deps
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- '.github/workflows/integration-reusable.yml'
build-and-test:
name: Build and Test
runs-on: buildjet-8vcpu-ubuntu-2204
runs-on: ubuntu-latest-16-cores
needs: changes
if: |
inputs.changes == false ||
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/program-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

build-lint-and-test:
name: Build Lint and Test
runs-on: buildjet-8vcpu-ubuntu-2204
runs-on: ubuntu-latest-16-cores
needs: changes
if: |
inputs.changes == false ||
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/program.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
- name: "fixed-price-sale"
- name: "gumdrop"
- name: "hydra"
- name: "nft-packs"
- name: "token-entangler"

uses: ./.github/workflows/program-reusable.yml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-lib-on-pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
needs: [get-changes-scope]
# note: checking for empty string just doesn't work, so we explicitly return and check null in the case that there's nothing to verify
if: ${{ needs.get-changes-scope.outputs.packages != 'null' }}
runs-on: buildjet-16vcpu-ubuntu-2204
runs-on: ubuntu-latest-16-cores
steps:
# branch should be the branch from which the PR is opened
- uses: actions/checkout@v3
Expand Down
10 changes: 5 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function exists_in_list() {

input=$1

programs="auction-house auctioneer candy-machine candy-machine-core fixed-price-sale gumdrop hydra nft-packs token-entangler"
programs="auction-house auctioneer candy-machine fixed-price-sale gumdrop hydra token-entangler"

mkdir -p test-programs

Expand All @@ -28,10 +28,10 @@ then
cargo build-bpf --bpf-out-dir ../../test-programs/
cd ../../
done
echo "building testing-utils"
cd core/rust/testing-utils
cargo build-bpf --bpf-out-dir ../../../test-programs/
cd ../../../
#echo "building testing-utils"
#cd core/rust/testing-utils
#cargo build-bpf --bpf-out-dir ../../../test-programs/
#cd ../../../
elif [[ $input = "token-auth-rules" ]]
then
solana program dump -u https://api.mainnet-beta.solana.com auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg ./test-programs/mpl_token_auth_rules.so
Expand Down
280 changes: 0 additions & 280 deletions candy-machine/program/tests/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,283 +92,3 @@ async fn init_default_success() {
assert_account_empty(context, &candy_manager.collection_info.pda).await;
assert!(post_balance > pre_balance);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn bot_tax_on_gatekeeper_expire_token() {
test_start("Bot Tax On Gatekeeper Expire Token");
let mut context = candy_machine_program_test().start_with_context().await;
let context = &mut context;

let gatekeeper_network = Keypair::new();
let gatekeeper_authority = Keypair::new();

let client = RpcClient::new("https://api.devnet.solana.com".to_string());

let gateway_account_pubkey = GATEWAY_ACCOUNT_PUBKEY;
let gateway_executable_pubkey =
Pubkey::from_str("D5iXG4Z4hajVFAs8UbmBwdfe7PFqvoT4LNVvt1nKU5bx").unwrap();
let gateway_account = client.get_account(&gateway_account_pubkey).unwrap();
let gateway_executable_account = client.get_account(&gateway_executable_pubkey).unwrap();
context.set_account(&gateway_account_pubkey, &gateway_account.into());
context.set_account(
&gateway_executable_pubkey,
&gateway_executable_account.into(),
);

let mut candy_manager = CandyManager::init(
context,
None,
false,
None,
None,
Some(GatekeeperInfo {
set: true,
network_expire_feature: None,
gateway_app: GATEWAY_ACCOUNT_PUBKEY,
gateway_token_info: gatekeeper_network.pubkey(),
gatekeeper_config: GatekeeperConfig {
gatekeeper_network: gatekeeper_network.pubkey(),
expire_on_use: true,
},
}),
)
.await;

airdrop(context, &candy_manager.minter.pubkey(), sol(2.0))
.await
.unwrap();

let candy_data = custom_config(
candy_manager.authority.pubkey(),
Some(0),
true,
true,
None,
None,
None,
Some(GKConfig {
gatekeeper_network: gatekeeper_network.pubkey(),
expire_on_use: true,
}),
);

candy_manager
.create(context, candy_data.clone())
.await
.unwrap();
candy_manager.fill_config_lines(context).await.unwrap();

let block_hash = context.banks_client.get_latest_blockhash().await.unwrap();
let transaction = Transaction::new_signed_with_payer(
&[instruction::add_gatekeeper(
&candy_manager.minter.pubkey(),
&gatekeeper_authority.pubkey(),
&gatekeeper_network.pubkey(),
)],
Some(&candy_manager.minter.pubkey()),
&[&candy_manager.minter, &gatekeeper_network],
block_hash,
);

context
.banks_client
.process_transaction(transaction)
.await
.unwrap();

let (gatekeeper_account, _) = get_gatekeeper_address_with_seed(
&gatekeeper_authority.pubkey(),
&gatekeeper_network.pubkey(),
);

let start = SystemTime::now();
let now = start
.duration_since(UNIX_EPOCH)
.expect("Time went backwards");

// creating with an already expired token to fail the mint
let block_hash = context.banks_client.get_latest_blockhash().await.unwrap();
let transaction = Transaction::new_signed_with_payer(
&[instruction::issue_vanilla(
&context.payer.pubkey(),
&candy_manager.minter.pubkey(),
&gatekeeper_account,
&gatekeeper_authority.pubkey(),
&gatekeeper_network.pubkey(),
None,
Some(now.as_secs() as UnixTimestamp - 10),
)],
Some(&context.payer.pubkey()),
&[&context.payer, &gatekeeper_authority],
block_hash,
);

context
.banks_client
.process_transaction(transaction)
.await
.unwrap();

let block_hash = context.banks_client.get_latest_blockhash().await.unwrap();
context
.banks_client
.process_transaction(Transaction::new_signed_with_payer(
&[instruction::add_feature_to_network(
context.payer.pubkey(),
gatekeeper_network.pubkey(),
NetworkFeature::UserTokenExpiry,
)],
Some(&context.payer.pubkey()),
&[&context.payer, &gatekeeper_network],
block_hash,
))
.await
.unwrap();

candy_manager
.mint_and_assert_bot_tax(context)
.await
.unwrap();
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn bot_tax_on_gatekeeper() {
test_start("Bot Tax On Gatekeeper");
let mut context = candy_machine_program_test().start_with_context().await;
let context = &mut context;

let gatekeeper_network = Keypair::new();
let gatekeeper_authority = Keypair::new();

let client = RpcClient::new("https://api.devnet.solana.com".to_string());

let gateway_account_pubkey = GATEWAY_ACCOUNT_PUBKEY;
let gateway_executable_pubkey =
Pubkey::from_str("D5iXG4Z4hajVFAs8UbmBwdfe7PFqvoT4LNVvt1nKU5bx").unwrap();
let gateway_account = client.get_account(&gateway_account_pubkey).unwrap();
let gateway_executable_account = client.get_account(&gateway_executable_pubkey).unwrap();
context.set_account(&gateway_account_pubkey, &gateway_account.into());
context.set_account(
&gateway_executable_pubkey,
&gateway_executable_account.into(),
);

let mut candy_manager = CandyManager::init(
context,
None,
false,
None,
None,
Some(GatekeeperInfo {
set: true,
network_expire_feature: None,
gateway_app: GATEWAY_ACCOUNT_PUBKEY,
gateway_token_info: gatekeeper_network.pubkey(),
gatekeeper_config: GatekeeperConfig {
gatekeeper_network: gatekeeper_network.pubkey(),
expire_on_use: false,
},
}),
)
.await;

airdrop(context, &candy_manager.minter.pubkey(), sol(2.0))
.await
.unwrap();

let candy_data = custom_config(
candy_manager.authority.pubkey(),
Some(0),
true,
true,
None,
None,
None,
Some(GKConfig {
gatekeeper_network: gatekeeper_network.pubkey(),
expire_on_use: false,
}),
);

candy_manager
.create(context, candy_data.clone())
.await
.unwrap();
candy_manager.fill_config_lines(context).await.unwrap();

let block_hash = context.banks_client.get_latest_blockhash().await.unwrap();
let transaction = Transaction::new_signed_with_payer(
&[instruction::add_gatekeeper(
&candy_manager.minter.pubkey(),
&gatekeeper_authority.pubkey(),
&gatekeeper_network.pubkey(),
)],
Some(&candy_manager.minter.pubkey()),
&[&candy_manager.minter, &gatekeeper_network],
block_hash,
);

context
.banks_client
.process_transaction(transaction)
.await
.unwrap();

let (gatekeeper_account, _) = get_gatekeeper_address_with_seed(
&gatekeeper_authority.pubkey(),
&gatekeeper_network.pubkey(),
);

let block_hash = context.banks_client.get_latest_blockhash().await.unwrap();
let transaction = Transaction::new_signed_with_payer(
&[instruction::issue_vanilla(
&context.payer.pubkey(),
&candy_manager.minter.pubkey(),
&gatekeeper_account,
&gatekeeper_authority.pubkey(),
&gatekeeper_network.pubkey(),
None,
None,
)],
Some(&context.payer.pubkey()),
&[&context.payer, &gatekeeper_authority],
block_hash,
);

context
.banks_client
.process_transaction(transaction)
.await
.unwrap();

let (gateway_account, _) = get_gateway_token_address_with_seed(
&candy_manager.minter.pubkey(),
&None,
&gatekeeper_network.pubkey(),
);

let block_hash = context.banks_client.get_latest_blockhash().await.unwrap();
// revoking the token so verification fails inside of gateway triggering bot tax
let transaction = Transaction::new_signed_with_payer(
&[instruction::set_state(
&gateway_account,
&gatekeeper_authority.pubkey(),
&gatekeeper_account,
GatewayTokenState::Revoked,
)],
Some(&context.payer.pubkey()),
&[&context.payer, &gatekeeper_authority],
block_hash,
);

context
.banks_client
.process_transaction(transaction)
.await
.unwrap();

candy_manager
.mint_and_assert_bot_tax(context)
.await
.unwrap();
}
2 changes: 1 addition & 1 deletion candy-machine/program/tests/utils/candy_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ impl CandyManager {
}

let sol_fees = {
let mut fees = 5000 + 5616720 + 2853600;
let mut fees = 5000 + 5616720 + 2853600 + 10000000;
if self.freeze_info.set {
let freeze_pda = self.get_freeze_pda(context).await;
fees += freeze_pda.freeze_fee;
Expand Down
Loading

0 comments on commit 23789d8

Please sign in to comment.