瀏覽代碼

:white_check_mark: Adding CU measurement in tests

Danilo Guanabara 2 月之前
父節點
當前提交
90cb40982d

+ 6 - 0
Anchor.toml

@@ -15,6 +15,8 @@ position = "Fn1JzzEdyb55fsyduWS94mYHizGhJZuhvjX6DVvrmGbQ"
 system-apply-velocity = "6LHhFVwif6N9Po3jHtSmMVtPjF6zRfL3xMosSzcrQAS8"
 system-fly = "HT2YawJjkNmqWcLNfPAMvNsLdWwPvvvbKA5bpMw4eUpq"
 system-simple-movement = "FSa6qoJXFBR3a7ThQkTAMrC15p6NkchPEjBdd4n6dXxA"
+system-with-few-components = "A3kNNSgmkTNA5V1qtnrbtNeqKrYHNxUMCTkqTDaQzE97"
+system-with-many-components = "Hi4sMEb3uXhWCiLyrF7t3Z384an7YZsTj774cabAAPQB"
 velocity = "CbHEFbSQdRN4Wnoby9r16umnJ1zWbULBHg4yqzGQonU1"
 with-1-component = "BsVKJF2H9GN1P9WrexdgEY4ztiweKvfQo6ydLWUEw6n7"
 with-2-components = "X5wTvz1i6ocNXzfrEB8JmhFCniojUZxqk3TXDq98fZX"
@@ -35,7 +37,11 @@ cluster = "localnet"
 wallet = "./tests/fixtures/provider.json"
 
 [workspace]
+<<<<<<< HEAD
 members = ["crates/programs/bolt-component", "crates/programs/bolt-system", "crates/programs/world", "examples/component-position", "examples/component-velocity", "examples/system-apply-velocity", "examples/system-fly", "examples/system-simple-movement", "examples/component-small", "examples/system-with-1-component", "examples/system-with-2-components", "examples/system-with-3-components", "examples/system-with-4-components", "examples/system-with-5-components", "examples/system-with-6-components", "examples/system-with-7-components", "examples/system-with-8-components", "examples/system-with-9-components", "examples/system-with-10-components"]
+=======
+members = ["crates/programs/bolt-component", "crates/programs/bolt-system", "crates/programs/world", "examples/component-position", "examples/component-velocity", "examples/system-apply-velocity", "examples/system-fly", "examples/system-simple-movement", "examples/system-with-many-components", "examples/system-with-few-components", "examples/component-large", "examples/component-small"]
+>>>>>>> f665350 (:white_check_mark: Adding CU measurement in tests)
 
 [scripts]
 test = "tests/script.sh"

+ 25 - 0
Cargo.lock

@@ -1258,6 +1258,13 @@ dependencies = [
  "memchr",
 ]
 
+[[package]]
+name = "component-large"
+version = "0.2.4"
+dependencies = [
+ "bolt-lang",
+]
+
 [[package]]
 name = "component-small"
 version = "0.2.4"
@@ -5910,6 +5917,24 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "system-with-few-components"
+version = "0.2.4"
+dependencies = [
+ "bolt-lang",
+ "component-large",
+ "serde",
+]
+
+[[package]]
+name = "system-with-many-components"
+version = "0.2.4"
+dependencies = [
+ "bolt-lang",
+ "component-small",
+ "serde",
+]
+
 [[package]]
 name = "tar"
 version = "0.4.43"

+ 1 - 0
Cargo.toml

@@ -8,6 +8,7 @@ members = [
     "crates/programs/world",
     "crates/types",
     "examples/*",
+    "examples/system-with-many-components",
 ]
 
 [workspace.package]

+ 1 - 3
clients/typescript/test/framework.ts

@@ -61,6 +61,7 @@ export class Framework {
   componentPositionEntity1Pda: PublicKey;
   componentVelocityEntity1Pda: PublicKey;
   componentPositionEntity4Pda: PublicKey;
+  componentSmallEntity1Pda: PublicKey;
 
   constructor() {
     this.secondAuthority = Keypair.generate().publicKey;
@@ -70,9 +71,6 @@ export class Framework {
     this.systemSimpleMovement = anchor.workspace.SystemSimpleMovement;
     this.systemFly = anchor.workspace.SystemFly;
     this.systemApplyVelocity = anchor.workspace.SystemApplyVelocity;
-    this.systemWithManyComponents = anchor.workspace.SystemWithManyComponents;
-    this.systemWithFewComponents = anchor.workspace.SystemWithFewComponents;
-    this.componentLarge = anchor.workspace.Large;
     this.componentSmall = anchor.workspace.Small;
     this.systemWith1Component = anchor.workspace.With1Component;
     this.systemWith2Components = anchor.workspace.With2Components;

+ 1 - 1
clients/typescript/test/low-level/permissioning/world.ts

@@ -103,7 +103,7 @@ export function world(framework) {
         .instruction();
       let transaction = new anchor.web3.Transaction().add(instruction);
       await framework.provider.sendAndConfirm(transaction, [], {
-        skipPreflight: true
+        skipPreflight: true,
       });
 
       // Get World and check permissionless and systems

+ 22 - 0
examples/component-large/Cargo.toml

@@ -0,0 +1,22 @@
+[package]
+name = "component-large"
+version.workspace = true
+edition.workspace = true
+
+[lib]
+crate-type = ["cdylib", "lib"]
+name = "component_large"
+
+[features]
+no-entrypoint = []
+no-idl = []
+no-log-ix-name = []
+cpi = ["no-entrypoint"]
+default = []
+idl-build = ["bolt-lang/idl-build"]
+anchor-debug = ["bolt-lang/anchor-debug"]
+custom-heap = []
+custom-panic = []
+
+[dependencies]
+bolt-lang.workspace = true

+ 2 - 0
examples/component-large/Xargo.toml

@@ -0,0 +1,2 @@
+[target.bpfel-unknown-unknown.dependencies.std]
+features = []

+ 17 - 0
examples/component-large/src/lib.rs

@@ -0,0 +1,17 @@
+use bolt_lang::*;
+
+declare_id!("FJjiJoz799Q6NqYffXbsFFj1pBmwsQZgcoizCfWvM5HX");
+
+#[component]
+pub struct Large {
+    pub value: [u8; 32],
+}
+
+impl Default for Large {
+    fn default() -> Self {
+        Self {
+            bolt_metadata: BoltMetadata::default(),
+            value: [0; 32],
+        }
+    }
+}

+ 26 - 0
examples/system-with-few-components/Cargo.toml

@@ -0,0 +1,26 @@
+[package]
+name = "system-with-few-components"
+version = "0.2.4"
+description = "Created with Bolt"
+edition = "2021"
+
+[lib]
+crate-type = ["cdylib", "lib"]
+name = "system_with_few_components"
+
+[features]
+no-entrypoint = []
+no-idl = []
+no-log-ix-name = []
+cpi = ["no-entrypoint"]
+default = []
+idl-build = ["bolt-lang/idl-build"]
+anchor-debug = ["bolt-lang/anchor-debug"]
+custom-heap = []
+custom-panic = []
+
+
+[dependencies]
+bolt-lang.workspace = true
+serde.workspace = true 
+component-large.workspace = true

+ 2 - 0
examples/system-with-few-components/Xargo.toml

@@ -0,0 +1,2 @@
+[target.bpfel-unknown-unknown.dependencies.std]
+features = []

+ 23 - 0
examples/system-with-few-components/src/lib.rs

@@ -0,0 +1,23 @@
+use bolt_lang::*;
+use component_large::Large;
+
+declare_id!("A3kNNSgmkTNA5V1qtnrbtNeqKrYHNxUMCTkqTDaQzE97");
+
+
+#[system]
+pub mod system_with_few_components {
+
+    pub fn execute(ctx: Context<Components>, _args_p: Vec<u8>) -> Result<Components> {
+        Ok(ctx.accounts)
+    }
+
+    #[system_input]
+    pub struct Components {
+        pub large1: Large,
+        pub large2: Large,
+        pub large3: Large,
+        pub large4: Large,
+        pub large5: Large,
+    }
+
+}

+ 25 - 0
examples/system-with-many-components/Cargo.toml

@@ -0,0 +1,25 @@
+[package]
+name = "system-with-many-components"
+version.workspace = true
+edition.workspace = true
+
+[lib]
+crate-type = ["cdylib", "lib"]
+name = "system_with_many_components"
+
+[features]
+no-entrypoint = []
+no-idl = []
+no-log-ix-name = []
+cpi = ["no-entrypoint"]
+default = []
+idl-build = ["bolt-lang/idl-build"]
+anchor-debug = ["bolt-lang/anchor-debug"]
+custom-heap = []
+custom-panic = []
+
+
+[dependencies]
+bolt-lang.workspace = true
+component-small.workspace = true
+serde.workspace = true

+ 2 - 0
examples/system-with-many-components/Xargo.toml

@@ -0,0 +1,2 @@
+[target.bpfel-unknown-unknown.dependencies.std]
+features = []

+ 27 - 0
examples/system-with-many-components/src/lib.rs

@@ -0,0 +1,27 @@
+use bolt_lang::*;
+use component_small::Small;
+
+declare_id!("Hi4sMEb3uXhWCiLyrF7t3Z384an7YZsTj774cabAAPQB");
+
+#[system]
+pub mod system_with_many_components {
+
+    pub fn execute(ctx: Context<Components>, _args_p: Vec<u8>) -> Result<Components> {
+        Ok(ctx.accounts)
+    }
+
+    #[system_input]
+    pub struct Components {
+        pub small1: Small,
+        pub small2: Small,
+        pub small3: Small,
+        pub small4: Small,
+        pub small5: Small,
+        pub small6: Small,
+        pub small7: Small,
+        pub small8: Small,
+        pub small9: Small,
+        pub small10: Small,
+    }
+
+}