Skip to content

Commit

Permalink
saving progress before meeting
Browse files Browse the repository at this point in the history
  • Loading branch information
crypto-vincent committed Jun 17, 2024
1 parent 86bda9e commit 592982a
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions tests/bolt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ describe("bolt", () => {

let entity1Pda: PublicKey;
let entity2Pda: PublicKey;
let entity4Pda: PublicKey;
let entity5Pda: PublicKey;

let componentPositionEntity1Pda: PublicKey;
let componentVelocityEntity1Pda: PublicKey;

let componentPositionEntity2Pda: PublicKey;
let componentPositionEntity4Pda: PublicKey;
let componentPositionEntity5Pda: PublicKey;

it("InitializeRegistry", async () => {
Expand Down Expand Up @@ -163,6 +165,7 @@ describe("bolt", () => {
connection: provider.connection,
});
await provider.sendAndConfirm(addEntity.transaction);
entity4Pda = addEntity.entityPda;
});

it("Add entity 5", async () => {
Expand Down Expand Up @@ -226,6 +229,16 @@ describe("bolt", () => {
componentPositionEntity2Pda = initializeComponent.componentPda; // Saved for later
});

it("Initialize Position Component on Entity 4", async () => {
const initializeComponent = await InitializeComponent({
payer: provider.wallet.publicKey,
entity: entity4Pda,
componentId: exampleComponentPosition.programId,
});
await provider.sendAndConfirm(initializeComponent.transaction);
componentPositionEntity4Pda = initializeComponent.componentPda; // Saved for later
});

it("Initialize Position Component on Entity 5 (with authority)", async () => {
const initializeComponent = await InitializeComponent({
payer: provider.wallet.publicKey,
Expand Down Expand Up @@ -393,8 +406,29 @@ describe("bolt", () => {
expect(position.z.toNumber()).to.equal(300);
});

// Check illegal authority usage
it("Check invalid component update (Entity 5, wrong authority)", async () => {
it("Fly System on Entity 4", async () => {
const applySystem = await ApplySystem({
authority: provider.wallet.publicKey,
systemId: exampleSystemFly,
entities: [
{
entity: entity4Pda,
components: [{ componentId: exampleComponentPosition.programId }],
},
],
});
await provider.sendAndConfirm(applySystem.transaction);

const position = await exampleComponentPosition.account.position.fetch(
componentPositionEntity4Pda
);
logPosition("Fly System: Entity 4", position);
expect(position.x.toNumber()).to.equal(1);
expect(position.y.toNumber()).to.equal(1);
expect(position.z.toNumber()).to.equal(1);
});

it("Fly System on Entity 5 (should fail with wrong authority)", async () => {
const positionBefore =
await exampleComponentPosition.account.position.fetch(
componentPositionEntity5Pda
Expand Down

0 comments on commit 592982a

Please sign in to comment.