Explorar el Código

✅ Fix C# tests (#148)

Danilo Guanabara hace 7 meses
padre
commit
c49a4aaa98

+ 6 - 5
clients/csharp/Solana.Unity.Bolt.Test/ECSTest.cs

@@ -17,13 +17,14 @@ namespace ECSTest {
             await AddEntity2(framework);
             await AddEntity2(framework);
             await AddEntity3(framework);
             await AddEntity3(framework);
             await AddEntity4WithSeed(framework);
             await AddEntity4WithSeed(framework);
-            await InitializeComponentVelocityOnEntity1WithSeed(framework);
+            await InitializeVelocityComponentOnEntity1WithSeed(framework);
             await InitializePositionComponentOnEntity1(framework);
             await InitializePositionComponentOnEntity1(framework);
             await InitializePositionComponentOnEntity2(framework);
             await InitializePositionComponentOnEntity2(framework);
             await InitializePositionComponentOnEntity4(framework);
             await InitializePositionComponentOnEntity4(framework);
             await CheckPositionOnEntity1IsDefault(framework);
             await CheckPositionOnEntity1IsDefault(framework);
             await ApplySimpleMovementSystemUpOnEntity1(framework);
             await ApplySimpleMovementSystemUpOnEntity1(framework);
             await ApplySimpleMovementSystemRightOnEntity1(framework);
             await ApplySimpleMovementSystemRightOnEntity1(framework);
+            await DestroyVelocityComponentOnEntity1(framework);
         }
         }
 
 
         public static async Task AddEntity1(Framework framework) {
         public static async Task AddEntity1(Framework framework) {
@@ -49,8 +50,8 @@ namespace ECSTest {
             await framework.SendAndConfirmInstruction(addEntity.Instruction);
             await framework.SendAndConfirmInstruction(addEntity.Instruction);
         }
         }
 
 
-        public static async Task InitializeComponentVelocityOnEntity1WithSeed(Framework framework) {
-            var initializeComponent = await Bolt.World.InitializeComponent(framework.Wallet.Account.PublicKey, framework.Entity1Pda, framework.ExampleComponentVelocity, "component-velocity");
+        public static async Task InitializeVelocityComponentOnEntity1WithSeed(Framework framework) {
+            var initializeComponent = await Bolt.World.InitializeComponent(framework.Wallet.Account.PublicKey, framework.Entity1Pda, framework.ExampleComponentVelocity, "component-velocity", framework.Wallet.Account.PublicKey);
             framework.ComponentVelocityEntity1Pda = initializeComponent.Pda;
             framework.ComponentVelocityEntity1Pda = initializeComponent.Pda;
             await framework.SendAndConfirmInstruction(initializeComponent.Instruction);
             await framework.SendAndConfirmInstruction(initializeComponent.Instruction);
         }
         }
@@ -126,11 +127,11 @@ namespace ECSTest {
 
 
             var componentBalance = await framework.Client.GetBalanceAsync(framework.ComponentVelocityEntity1Pda);
             var componentBalance = await framework.Client.GetBalanceAsync(framework.ComponentVelocityEntity1Pda);
 
 
-            var destroyComponent = await Bolt.World.DestroyComponent(framework.Wallet.Account.PublicKey, receiver.Account.PublicKey, framework.Entity1Pda, framework.ExampleComponentVelocity);
+            var destroyComponent = await Bolt.World.DestroyComponent(framework.Wallet.Account.PublicKey, receiver.Account.PublicKey, framework.Entity1Pda, framework.ExampleComponentVelocity, "component-velocity");
             await framework.SendAndConfirmInstruction(destroyComponent.Instruction);
             await framework.SendAndConfirmInstruction(destroyComponent.Instruction);
 
 
             var receiverBalance = await framework.Client.GetBalanceAsync(receiver.Account.PublicKey);
             var receiverBalance = await framework.Client.GetBalanceAsync(receiver.Account.PublicKey);
-            Assert.AreEqual(componentBalance, receiverBalance);
+            Assert.AreEqual(componentBalance.Result.Value, receiverBalance.Result.Value);
         }
         }
    }
    }
 }
 }

+ 0 - 4
clients/csharp/Solana.Unity.Bolt.Test/Main.cs

@@ -1,9 +1,5 @@
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Solana.Unity.Rpc.Models;
-using System;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using World.Program;
-using Solana.Unity.Programs;
 
 
 namespace Solana.Unity.Bolt.Test
 namespace Solana.Unity.Bolt.Test
 {
 {

+ 3 - 5
clients/csharp/Solana.Unity.Bolt.Test/SessionTest.cs

@@ -1,4 +1,3 @@
-
 using GplSession.Program;
 using GplSession.Program;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Solana.Unity.Bolt.Test;
 using Solana.Unity.Bolt.Test;
@@ -15,6 +14,7 @@ namespace SessionTest {
             await CreateSession(framework);
             await CreateSession(framework);
             await AddEntity(framework);
             await AddEntity(framework);
             await InitializePositionComponent(framework);
             await InitializePositionComponent(framework);
+            await ApplyFlySystemOnComponentUsingSessionToken(framework);
         }
         }
 
 
         public static async Task CreateSession(Framework framework) {
         public static async Task CreateSession(Framework framework) {
@@ -25,7 +25,7 @@ namespace SessionTest {
                 Authority = framework.Wallet.Account.PublicKey,
                 Authority = framework.Wallet.Account.PublicKey,
                 TargetProgram = new PublicKey(WorldProgram.ID)
                 TargetProgram = new PublicKey(WorldProgram.ID)
             };
             };
-            var instruction = GplSessionProgram.CreateSession(createSession, true, 1000, 100000000);
+            var instruction = GplSessionProgram.CreateSession(createSession, true, null, 100000000);
             await framework.SendAndConfirmInstruction(instruction, new List<Account> { framework.Wallet.Account, framework.SessionSigner.Account });
             await framework.SendAndConfirmInstruction(instruction, new List<Account> { framework.Wallet.Account, framework.SessionSigner.Account });
         }
         }
         
         
@@ -45,9 +45,7 @@ namespace SessionTest {
             var instruction = Bolt.World.ApplySystem(
             var instruction = Bolt.World.ApplySystem(
                 framework.WorldPda,
                 framework.WorldPda,
                 framework.SystemSimpleMovement,
                 framework.SystemSimpleMovement,
-                new Bolt.World.EntityType[] {
-                    new Bolt.World.EntityType(framework.SessionEntityPda, new PublicKey[] { framework.ExampleComponentPosition })
-                },
+                [new Bolt.World.EntityType(framework.SessionEntityPda, [framework.ExampleComponentPosition])],
                 new { direction = "Right" },
                 new { direction = "Right" },
                 framework.SessionSigner.Account.PublicKey,
                 framework.SessionSigner.Account.PublicKey,
                 framework.SessionToken
                 framework.SessionToken

+ 8 - 8
clients/csharp/Solana.Unity.Bolt/WorldProgram/Bolt/InitializeComponent.cs

@@ -12,28 +12,28 @@ namespace Bolt {
             public TransactionInstruction Instruction { get; set; }
             public TransactionInstruction Instruction { get; set; }
         }
         }
 
 
-                public static async Task<InitializeComponentInstruction> InitializeComponent(PublicKey payer, PublicKey entity, PublicKey componentId, byte[] seed) {
+        public static async Task<InitializeComponentInstruction> InitializeComponent(PublicKey payer, PublicKey entity, PublicKey componentId, byte[] seed, PublicKey authority = null) {
             var componentPda = WorldProgram.FindComponentPda(componentId, entity, seed);
             var componentPda = WorldProgram.FindComponentPda(componentId, entity, seed);
-            return await InitializeComponent(payer, entity, componentId, componentPda);
+            return await InitializeComponent(payer, entity, componentId, componentPda, authority);
         }
         }
 
 
-        public static async Task<InitializeComponentInstruction> InitializeComponent(PublicKey payer, PublicKey entity, PublicKey componentId, string seed) {
+        public static async Task<InitializeComponentInstruction> InitializeComponent(PublicKey payer, PublicKey entity, PublicKey componentId, string seed, PublicKey authority = null) {
             var componentPda = WorldProgram.FindComponentPda(componentId, entity, seed);
             var componentPda = WorldProgram.FindComponentPda(componentId, entity, seed);
-            return await InitializeComponent(payer, entity, componentId, componentPda);
+            return await InitializeComponent(payer, entity, componentId, componentPda, authority);
         }
         }
 
 
-        public static async Task<InitializeComponentInstruction> InitializeComponent(PublicKey payer, PublicKey entity, PublicKey componentId) {
+        public static async Task<InitializeComponentInstruction> InitializeComponent(PublicKey payer, PublicKey entity, PublicKey componentId, PublicKey authority = null) {
             var componentPda = WorldProgram.FindComponentPda(componentId, entity);
             var componentPda = WorldProgram.FindComponentPda(componentId, entity);
-            return await InitializeComponent(payer, entity, componentId, componentPda);
+            return await InitializeComponent(payer, entity, componentId, componentPda, authority);
         }
         }
 
 
-        public static async Task<InitializeComponentInstruction> InitializeComponent(PublicKey payer, PublicKey entity, PublicKey componentId, PublicKey componentPda) {
+        public static async Task<InitializeComponentInstruction> InitializeComponent(PublicKey payer, PublicKey entity, PublicKey componentId, PublicKey componentPda, PublicKey authority = null) {
             var initializeComponent = new InitializeComponentAccounts() {
             var initializeComponent = new InitializeComponentAccounts() {
                 Payer = payer,
                 Payer = payer,
                 Entity = entity,
                 Entity = entity,
                 Data = componentPda,
                 Data = componentPda,
                 ComponentProgram = componentId,
                 ComponentProgram = componentId,
-                Authority = new PublicKey(WorldProgram.ID)
+                Authority = authority ?? new PublicKey(WorldProgram.ID)
             };
             };
             var instruction = WorldProgram.InitializeComponent(initializeComponent);
             var instruction = WorldProgram.InitializeComponent(initializeComponent);
             return new InitializeComponentInstruction() {
             return new InitializeComponentInstruction() {

+ 1 - 1
clients/typescript/package.json

@@ -31,7 +31,7 @@
   "main": "lib/index.js",
   "main": "lib/index.js",
   "scripts": {
   "scripts": {
     "clean": "rimraf lib",
     "clean": "rimraf lib",
-    "build": "cp ../../../target/types/world.ts src/generated/types/world.ts && cp ../../../target/idl/world.json src/generated/idl/world.json && npm run clean && tsc && npm run lint:fix",
+    "build": "cp ../../target/types/world.ts src/generated/types/world.ts && cp ../../target/idl/world.json src/generated/idl/world.json && npm run clean && tsc && npm run lint:fix",
     "build:docs": "typedoc && typedoc --plugin typedoc-plugin-markdown --out docs-mk",
     "build:docs": "typedoc && typedoc --plugin typedoc-plugin-markdown --out docs-mk",
     "dev": "tsc --watch",
     "dev": "tsc --watch",
     "start": "tsc",
     "start": "tsc",