Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update integration tests workflow #43

Merged
merged 9 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .env.example

This file was deleted.

20 changes: 15 additions & 5 deletions .github/workflows/tests-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
workflow_dispatch:

env:
RUST_TOOLCHAIN: 1.75.0
SOLANA_CLI_VERSION: 1.18.11
RUST_TOOLCHAIN: 1.82.0
SOLANA_CLI_VERSION: 2.1.1
ANCHOR_CLI_VERSION: 0.30.1

jobs:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
# 4. Install Solana CLI
- name: Install Solana
run: |
sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_CLI_VERSION }}/install)"
sh -c "$(curl -sSfL https://release.anza.xyz/v${{ env.SOLANA_CLI_VERSION }}/install)"
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Verify Solana Installation
run: solana --version
Expand Down Expand Up @@ -99,7 +99,17 @@ jobs:
- name: Install Node.js dependencies
run: yarn install

# 9. Run Anchor Tests (skip build step since we built earlier)
# 9. Run anchor keys sync 1
- name: Run Anchor Keys Sync 1
run: anchor keys sync
timeout-minutes: 1

# 10. Run anchor keys sync 2
- name: Run Anchor Keys Sync 2
run: anchor keys sync
timeout-minutes: 1

# 11. Run Anchor Tests (skip build step since we built earlier)
- name: Run Anchor Tests
run: anchor test
timeout-minutes: 15
Expand All @@ -110,4 +120,4 @@ jobs:
QASE_TESTOPS_RUN_TITLE: CI Automation Tests Run - Onchain Vault Integration Tests at branch ${{ env.BRANCH_NAME }}
QASE_TESTOPS_RUN_COMPLETE: true
QASE_CAPTURE_LOGS: true
QASE_ENVIRONMENT: local-tesnet
QASE_ENVIRONMENT: local-tesnet
2 changes: 1 addition & 1 deletion Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ initialize = "yarn run initialize"
process_report = "yarn run process_report"
set_roles = "yarn run set_roles"
shutdown_vault = "yarn run shutdown_vault"
test = "yarn run ts-mocha -r dotenv/config -p ./tsconfig.json -t 2000000 --require './tests/integration/setups/globalSetup.ts' --recursive --reporter mocha-qase-reporter 'tests/integration/**/*.test.ts'"
test = "yarn run ts-mocha -r dotenv/config -p ./tsconfig.json -t 2000000 --require './tests/integration/setups/globalSetup.ts' --recursive 'tests/integration/**/*.test.ts'"
underlying_mint = "yarn run underlying_mint"
update_deposit_limit = "yarn run update-deposit-limit"
whitelist = "yarn run whitelist"
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"@metaplex-foundation/mpl-token-metadata": "^3.2.1",
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
"@metaplex-foundation/umi-signer-wallet-adapters": "^0.9.2",
"mocha-qase-reporter": "^1.0.0-beta.4",
"prettier": "^2.6.2",
"@solana/spl-token": "0.4.8",
"@solana/spl-token-metadata": "^0.1.5",
Expand Down
64 changes: 1 addition & 63 deletions tests/integration/tests/accessControl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import { BN } from "@coral-xyz/anchor";
import { airdrop } from "../../utils/helpers";

const { ROLES_ADMIN, ...ROLES_SUCCESS_DATA } = ROLES;
let qaseIdSetRoleTests = 82;
let qaseIdRevokeRoleTests = 90;

describe.only("Access Control Tests", () => {
describe("Access Control Tests", () => {
before(async () => {
console.log("-------Before Step Started-------");
await accessControlProgram.methods
Expand Down Expand Up @@ -68,7 +66,6 @@ describe.only("Access Control Tests", () => {
});

it("Initalizing access control program with super configOwner when it is already initialized should revert", async function () {
this.qaseId(76);
try {
await accessControlProgram.methods
.initialize()
Expand All @@ -84,7 +81,6 @@ describe.only("Access Control Tests", () => {
});

it("Initalizing access control program with another account when it is already initialized should revert", async function () {
this.qaseId(77);
const anotherconfigOwner = anchor.web3.Keypair.generate();
try {
await accessControlProgram.methods
Expand All @@ -101,7 +97,6 @@ describe.only("Access Control Tests", () => {
});

it("Setting Role Manager for any role with signer not being the config owner should revert", async function () {
this.qaseId(78);
const vaultAdminInner = anchor.web3.Keypair.generate();
await accessControlProgram.methods
.setRole(ROLES.VAULTS_ADMIN, vaultAdminInner.publicKey)
Expand All @@ -125,7 +120,6 @@ describe.only("Access Control Tests", () => {
});

it("Setting role manager with invalid role id should revert", async function () {
this.qaseId(79);
try {
await accessControlProgram.methods
.setRoleManager(new BN(10), ROLES.ROLES_ADMIN)
Expand All @@ -141,7 +135,6 @@ describe.only("Access Control Tests", () => {
});

it("Setting role manager with invalid manager role id should revert", async function () {
this.qaseId(80);
try {
await accessControlProgram.methods
.setRoleManager(ROLES.VAULTS_ADMIN, new BN(10))
Expand All @@ -157,7 +150,6 @@ describe.only("Access Control Tests", () => {
});

it("Setting ROLES_ADMIN role via set role method by the config owner should revert", async function () {
this.qaseId(81);
const roleReceiver = anchor.web3.Keypair.generate();
try {
await accessControlProgram.methods
Expand All @@ -177,8 +169,6 @@ describe.only("Access Control Tests", () => {

for (const role in ROLES_SUCCESS_DATA) {
it(`Setting ${role} role with signer being the corresponding role manager account is successful`, async function () {
this.qaseId(qaseIdSetRoleTests)
qaseIdSetRoleTests++;
const roleReceiver = anchor.web3.Keypair.generate();
if (role === "KYC_VERIFIED") {
// Set KYC Provider role to kycProvider account
Expand Down Expand Up @@ -234,7 +224,6 @@ describe.only("Access Control Tests", () => {
}

it("Setting multiple roles to the same account by corresponding role manager account is successful", async function () {
this.qaseId(88);
const roleReceiver = anchor.web3.Keypair.generate();
for (const role in ROLES_SUCCESS_DATA) {
if (role === "KYC_VERIFIED") {
Expand Down Expand Up @@ -293,7 +282,6 @@ describe.only("Access Control Tests", () => {
});

it("Setting a role via set role method by non role manager account should revert", async function () {
this.qaseId(89);
const roleReceiver = anchor.web3.Keypair.generate();
// KYC VERIFIED user's role manager is KYC_PROVIDER role, not ROLES_ADMIN
try {
Expand All @@ -314,8 +302,6 @@ describe.only("Access Control Tests", () => {

for (const role in ROLES_SUCCESS_DATA) {
it(`Revoking ${role} role with signer being the corresponding role manager account is successful`, async function () {
this.qaseId(qaseIdRevokeRoleTests);
qaseIdRevokeRoleTests++;
const roleReceiver = anchor.web3.Keypair.generate();
if (role === "KYC_VERIFIED") {
// Set KYC Provider role to kycProvider account
Expand Down Expand Up @@ -391,7 +377,6 @@ describe.only("Access Control Tests", () => {
}

it("Revoking a role that account did not have, with signer being the corresponding role manager should revert", async function () {
this.qaseId(96);
const roleReceiver = anchor.web3.Keypair.generate();
// Set Role
await accessControlProgram.methods
Expand Down Expand Up @@ -457,7 +442,6 @@ describe.only("Access Control Tests", () => {
});

it("Revoking role with invalid role_id with signer being the corresponding role manager is successful", async function () {
this.qaseId(97);
const roleReceiver = anchor.web3.Keypair.generate();
// Set Role
await accessControlProgram.methods
Expand Down Expand Up @@ -502,7 +486,6 @@ describe.only("Access Control Tests", () => {
});

it("Revoking one role from account that has multiple roles and signer being the corresponding role manager is successful", async function () {
this.qaseId(98);
const roleReceiver = anchor.web3.Keypair.generate();
// Set Role One
await accessControlProgram.methods
Expand Down Expand Up @@ -569,49 +552,4 @@ describe.only("Access Control Tests", () => {

assert.isTrue(roleReceiverStrategiesManagerRoleAccount.hasRole);
});

it("Revoking ROLES_ADMIN role from ROLES_ADMIN with signer being the config owner is successful", async function () {
this.qaseId(99);
await accessControlProgram.methods
.revokeRole(ROLES.ROLES_ADMIN, configOwner.publicKey)
.accounts({
signer: configOwner.publicKey,
recipient: configOwner.publicKey,
})
.signers([configOwner])
.rpc();

// No longer has ROLES_ADMIN role
const roleReceiverCorrespondingRole =
anchor.web3.PublicKey.findProgramAddressSync(
[
Buffer.from("user_role"),
configOwner.publicKey.toBuffer(),
ROLES_BUFFER.ROLES_ADMIN,
],
accessControlProgram.programId
)[0];

try {
await accessControlProgram.account.userRole.fetch(
roleReceiverCorrespondingRole
);
assert.fail("Error was not thrown");
} catch (err) {
expect(err.message).contains("Account does not exist or has no data");
}

// Confid owner account is still the config owner
const config = anchor.web3.PublicKey.findProgramAddressSync(
[Buffer.from("config")],
accessControlProgram.programId
)[0];
const configAccount = await accessControlProgram.account.config.fetch(
config
);
assert.equal(
configAccount.owner.toString(),
configOwner.publicKey.toString()
);
});
});
Loading