Skip to content

Commit 8cfe098

Browse files
test: mock intents contract for testing
1 parent 2c8ffda commit 8cfe098

File tree

7 files changed

+123
-5
lines changed

7 files changed

+123
-5
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ resolver = "2"
33
members = [
44
"contracts/intents-vault",
55
"contracts/solver-registry",
6+
"contracts/mock-intents",
67
]
78

89
[profile.release]

contracts/intents-vault/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use near_sdk::{assert_one_yocto, env, ext_contract, near, require, AccountId, Promise, PublicKey};
1+
use near_sdk::{assert_one_yocto, env, ext_contract, near, require, AccountId, NearToken, Promise, PublicKey};
22

33
#[allow(dead_code)]
44
#[ext_contract(ext_intents)]
@@ -21,7 +21,9 @@ impl Contract {
2121
assert_one_yocto();
2222
self.require_parent_account();
2323

24-
ext_intents::ext(intents_contract_id).add_public_key(public_key)
24+
ext_intents::ext(intents_contract_id)
25+
.with_attached_deposit(NearToken::from_yoctonear(1))
26+
.add_public_key(public_key)
2527
}
2628
}
2729

contracts/mock-intents/Cargo.toml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[package]
2+
name = "mock-intents"
3+
description = "Mocked Intents Contract for Testing"
4+
version = "0.1.0"
5+
edition = "2021"
6+
# NEP-0330 is automatically implemented for all contracts built with https://github.com/near/cargo-near.
7+
# Link to the repository will be available via `contract_source_metadata` view-function.
8+
repository = "https://github.com/near-intents/tee-solver/tree/main/contracts/mock-intents"
9+
10+
[lib]
11+
crate-type = ["cdylib", "rlib"]
12+
13+
# fields to configure build with WASM reproducibility, according to specs
14+
# in https://github.com/near/NEPs/blob/master/neps/nep-0330.md
15+
[package.metadata.near.reproducible_build]
16+
# docker image, descriptor of build environment
17+
image = "sourcescan/cargo-near:0.14.1-rust-1.86.0"
18+
# tag after colon above serves only descriptive purpose; image is identified by digest
19+
image_digest = "sha256:eaac91be3119cc7c136b6f375f2d3e092001f717ed6151ccc9d5348c2d6a640c"
20+
# list of environment variables names, whose values, if set, will be used as external build parameters
21+
# in a reproducible manner
22+
# supported by `sourcescan/cargo-near:0.10.1-rust-1.82.0` image or later images
23+
passed_env = []
24+
# build command inside of docker container
25+
# if docker image from default gallery is used https://hub.docker.com/r/sourcescan/cargo-near/tags,
26+
# the command may be any combination of flags of `cargo-near`,
27+
# supported by respective version of binary inside the container besides `--no-locked` flag
28+
container_build_command = [
29+
"cargo",
30+
"near",
31+
"build",
32+
"non-reproducible-wasm",
33+
"--locked",
34+
]
35+
36+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
37+
[dependencies]
38+
near-sdk = "5.14.0"
39+
serde_json = "1.0.140"
40+
41+
[dev-dependencies]
42+
near-sdk = { version = "5.14.0", features = ["unit-testing"] }
43+
tokio = "1.44.1"
44+
serde_json = "1.0.140"
45+
anyhow = "1.0.97"
46+
near-workspaces = { version = "0.20.1", features = ["unstable"]}
47+
near-gas = "0.3.0"
48+
49+
[profile.release]
50+
codegen-units = 1
51+
# Tell `rustc` to optimize for small code size.
52+
opt-level = "z"
53+
lto = true
54+
debug = false
55+
panic = "abort"
56+
# Opt into extra safety checks on arithmetic operations https://stackoverflow.com/a/64136471/249801
57+
overflow-checks = true

contracts/mock-intents/src/lib.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use std::collections::HashSet;
2+
use near_sdk::{assert_one_yocto, env, near, AccountId, BorshStorageKey, PublicKey, PanicOnDefault};
3+
use near_sdk::store::LookupMap;
4+
5+
#[derive(PanicOnDefault)]
6+
#[near(contract_state)]
7+
pub struct Contract {
8+
public_keys: LookupMap<AccountId, HashSet<PublicKey>>,
9+
}
10+
11+
#[near]
12+
#[derive(BorshStorageKey)]
13+
pub enum Prefix {
14+
PublicKeys
15+
}
16+
17+
#[near]
18+
impl Contract {
19+
#[init]
20+
#[private]
21+
pub fn new() -> Self {
22+
Self {
23+
public_keys: LookupMap::new(Prefix::PublicKeys)
24+
}
25+
}
26+
27+
#[payable]
28+
pub fn add_public_key(
29+
&mut self,
30+
public_key: PublicKey,
31+
) {
32+
assert_one_yocto();
33+
34+
let account_id = env::predecessor_account_id();
35+
let mut keys = self.internal_get_account(&account_id);
36+
keys.insert(public_key);
37+
self.public_keys.insert(account_id, keys.clone());
38+
}
39+
40+
pub fn public_keys_of(&self, account_id: AccountId) -> HashSet<PublicKey> {
41+
self.internal_get_account(&account_id)
42+
}
43+
44+
fn internal_get_account(&self, account_id: &AccountId) -> HashSet<PublicKey> {
45+
self.public_keys.get(account_id).unwrap_or(&HashSet::new()).clone()
46+
}
47+
}

contracts/solver-registry/tests/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub const CONTRACT_WASM: &str = "../../../target/near/solver_registry/solver_registry.wasm";
1+
pub const CONTRACT_WASM: &str = "../../target/near/solver_registry/solver_registry.wasm";
22

33
pub const QUOTE_HEX : &str = "040002008100000000000000939a7233f79c4ca9940a0db3957f0607ac666ed993e70e31ff5f5a8a2c743b220000000007010300000000000000000000000000c51e5cb16c461fe29b60394984755325ecd05a9a7a8fb3a116f1c3cf0aca4b0eb9edefb9b404deeaee4b7d454372d17a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000702000000000000c68518a0ebb42136c12b2275164f8c72f25fa9a34392228687ed6e9caeb9c0f1dbd895e9cf475121c029dc47e70e91fd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000085e0855a6384fa1c8a6ab36d0dcbfaa11a5753e5a070c08218ae5fe872fcb86967fd2449c29e22e59dc9fec998cb65474a7db64a609c77e85f603c23e9a9fd03bfd9e6b52ce527f774a598e66d58386026cea79b2aea13b81a0b70cfacdec0ca8a4fe048fea22663152ef128853caa5c033cbe66baf32ba1ff7f6b1afc1624c279f50a4cbc522a735ca6f69551e61ef2561c1b02351cd6f7c803dd36bc95ba25463aa025ce7761156260c9131a5d7c03aeccc10e12160ec3205bb2876a203a7fb81447910d62fd92897d68b1f51d54fb75dfe2aeba3a97a879cba59a771fc522d88046cc26b407d723f726fae17c3e5a50529d0b6c2b991d027f06a9b430d43ecc1000003bdd12b68ee3cfc93a1758479840b6f8734c2439106d8f0faa50ac919d86ea101c002c41d262670ad84afb8f9ee35c7abbb72dcc01bbc3e3a3773672d665005ee6bcb0c5f4b03f0563c797747f7ddd25d92d4f120bee4a829daca986bbc03c155b3d158f6a386bca7ee49ceb3ec31494b792e0cf22fc4e561ddc57156da1b77a0600461000000303070704ff00020000000000000000000000000000000000000000000000000000000000000000000000000000000015000000000000000700000000000000e5a3a7b5d830c2953b98534c6c59a3a34fdc34e933f7f5898f0a85cf08846bca0000000000000000000000000000000000000000000000000000000000000000dc9e2a7c6f948f17474e34a7fc43ed030f7c1563f1babddf6340c82e0e54a8c5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005d2eb8ae211693884eadaea0be0392c5532c7ff55429e4696c84954444d62ed600000000000000000000000000000000000000000000000000000000000000004f1cd2dde7dd5d4a9a495815f3ac76c56a77a9e06a5279a8c8550b54cf2d7287a630c3b9aefb94b1b6e8491eba4b43baa811c8f44167eb7d9ca933678ea64f5b2000000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f05005e0e00002d2d2d2d2d424547494e2043455254494649434154452d2d2d2d2d0a4d49494538544343424a656741774942416749554439426b736e734170713045567861464a59785a56794f6774664d77436759494b6f5a497a6a3045417749770a634445694d434147413155454177775a535735305a577767553064594946424453794251624746305a6d397962534244515445614d42674741315545436777520a535735305a577767513239796347397959585270623234784644415342674e564241634d43314e68626e526849454e7359584a684d51737743515944565151490a44414a445154454c4d416b474131554542684d4356564d774868634e4d6a55774d6a41334d5463774f4441325768634e4d7a49774d6a41334d5463774f4441320a576a42774d534977494159445651514444426c4a626e526c624342545231676755454e4c49454e6c636e52705a6d6c6a5958526c4d526f77474159445651514b0a4442464a626e526c6243424462334a7762334a6864476c76626a45554d424947413155454277774c553246756447456751327868636d4578437a414a42674e560a4241674d416b4e424d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424853770a3977506a72554532734f4a644c5653415434686565414a572b31796c6473615556696b5a4c485832506235777374326a79697539414f5865576a7a6a6d585a4c0a4343742b457858716f53394e45476c6b52724b6a67674d4e4d4949444354416642674e5648534d4547444157674253566231334e765276683655424a796454300a4d383442567776655644427242674e56485238455a4442694d47436758714263686c706f64485277637a6f764c32467761533530636e567a6447566b633256790a646d6c6a5a584d75615735305a577775593239744c334e6e6543396a5a584a3061575a7059324630615739754c3359304c33426a61324e796244396a595431770a624746305a6d397962535a6c626d4e765a476c755a7a316b5a584977485159445652304f42425945464d6a464e59626f7464634b636859487258467966774b460a774e534d4d41344741315564447745422f775145417749477744414d42674e5648524d4241663845416a41414d4949434f67594a4b6f5a496876684e415130420a424949434b7a4343416963774867594b4b6f5a496876684e41513042415151514134346b35686a336951797044574873756f5a474144434341575147436971470a534962345451454e41514977676746554d42414743797147534962345451454e41514942416745434d42414743797147534962345451454e41514943416745430a4d42414743797147534962345451454e41514944416745434d42414743797147534962345451454e41514945416745434d42414743797147534962345451454e0a41514946416745434d42454743797147534962345451454e41514947416749412f7a415142677371686b69472b453042445145434277494241444151426773710a686b69472b4530424451454343414942416a415142677371686b69472b45304244514543435149424144415142677371686b69472b45304244514543436749420a4144415142677371686b69472b45304244514543437749424144415142677371686b69472b45304244514543444149424144415142677371686b69472b4530420a44514543445149424144415142677371686b69472b45304244514543446749424144415142677371686b69472b453042445145434477494241444151426773710a686b69472b45304244514543454149424144415142677371686b69472b45304244514543455149424454416642677371686b69472b45304244514543456751510a4167494341674c2f4141494141414141414141414144415142676f71686b69472b45304244514544424149414144415542676f71686b69472b453042445145450a424159676f473841414141774477594b4b6f5a496876684e4151304242516f424154416542676f71686b69472b453042445145474242414b496f456755387a650a486d2b49596f7a686c337a314d45514743697147534962345451454e415163774e6a415142677371686b69472b45304244514548415145422f7a4151426773710a686b69472b45304244514548416745422f7a415142677371686b69472b45304244514548417745422f7a414b42676771686b6a4f5051514441674e49414442460a4169417362735a44796d2f72455a30476c454c62442f6e64755061536a485341746e5871567453313047486255774968414d585666784b334b666f4b675131660a4578397478765331314362363662323467424344523963477942562b0a2d2d2d2d2d454e442043455254494649434154452d2d2d2d2d0a2d2d2d2d2d424547494e2043455254494649434154452d2d2d2d2d0a4d4949436c6a4343416a32674177494241674956414a567658633239472b487051456e4a3150517a7a674658433935554d416f4743437147534d343942414d430a4d476778476a415942674e5642414d4d45556c756447567349464e48574342536232393049454e424d526f77474159445651514b4442464a626e526c624342440a62334a7762334a6864476c76626a45554d424947413155454277774c553246756447456751327868636d4578437a414a42674e564241674d416b4e424d5173770a435159445651514745774a56557a4165467730784f4441314d6a45784d4455774d5442614677307a4d7a41314d6a45784d4455774d5442614d484178496a41670a42674e5642414d4d47556c756447567349464e4857434251513073675547786864475a76636d306751304578476a415942674e5642416f4d45556c75644756730a49454e76636e4276636d4630615739754d5251774567594456515148444174545957353059534244624746795954454c4d416b474131554543417743513045780a437a414a42674e5642415954416c56544d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741454e53422f377432316c58534f0a3243757a7078773734654a423732457944476757357258437478327456544c7136684b6b367a2b5569525a436e71523770734f766771466553786c6d546c4a6c0a65546d693257597a33714f42757a43427544416642674e5648534d4547444157674251695a517a575770303069664f44744a5653763141624f536347724442530a42674e5648523845537a424a4d45656752614244686b466f64485277637a6f764c324e6c636e52705a6d6c6a5958526c63793530636e567a6447566b633256790a646d6c6a5a584d75615735305a577775593239744c306c756447567355306459556d397664454e424c6d526c636a416442674e5648513445466751556c5739640a7a62306234656c4153636e553944504f4156634c336c517744675944565230504151482f42415144416745474d42494741315564457745422f7751494d4159420a4166384341514177436759494b6f5a497a6a30454177494452774177524149675873566b6930772b6936565947573355462f32327561586530594a446a3155650a6e412b546a44316169356343494359623153416d4435786b66545670766f34556f79695359787244574c6d5552344349394e4b7966504e2b0a2d2d2d2d2d454e442043455254494649434154452d2d2d2d2d0a2d2d2d2d2d424547494e2043455254494649434154452d2d2d2d2d0a4d4949436a7a4343416a53674177494241674955496d554d316c71644e496e7a6737535655723951477a6b6e42717777436759494b6f5a497a6a3045417749770a614445614d4267474131554541777752535735305a5777675530645949464a766233516751304578476a415942674e5642416f4d45556c756447567349454e760a636e4276636d4630615739754d5251774567594456515148444174545957353059534244624746795954454c4d416b47413155454341774351304578437a414a0a42674e5642415954416c56544d423458445445344d4455794d5445774e4455784d466f58445451354d54497a4d54497a4e546b314f566f77614445614d4267470a4131554541777752535735305a5777675530645949464a766233516751304578476a415942674e5642416f4d45556c756447567349454e76636e4276636d46300a615739754d5251774567594456515148444174545957353059534244624746795954454c4d416b47413155454341774351304578437a414a42674e56424159540a416c56544d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414543366e45774d4449595a4f6a2f69505773437a61454b69370a314f694f534c52466857476a626e42564a66566e6b59347533496a6b4459594c304d784f346d717379596a6c42616c54565978465032734a424b357a6c4b4f420a757a43427544416642674e5648534d4547444157674251695a517a575770303069664f44744a5653763141624f5363477244425342674e5648523845537a424a0a4d45656752614244686b466f64485277637a6f764c324e6c636e52705a6d6c6a5958526c63793530636e567a6447566b63325679646d6c6a5a584d75615735300a5a577775593239744c306c756447567355306459556d397664454e424c6d526c636a416442674e564851344546675155496d554d316c71644e496e7a673753560a55723951477a6b6e4271777744675944565230504151482f42415144416745474d42494741315564457745422f7751494d4159424166384341514577436759490a4b6f5a497a6a3045417749445351417752674968414f572f35516b522b533943695344634e6f6f774c7550524c735747662f59693747535839344267775477670a41694541344a306c72486f4d732b586f356f2f7358364f39515778485241765a55474f6452513763767152586171493d0a2d2d2d2d2d454e442043455254494649434154452d2d2d2d2d0a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
44

contracts/solver-registry/tests/test_basics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub struct Worker {
1313
codehash: String,
1414
}
1515

16-
#[ignore = "ignore before fix failure"]
1716
#[tokio::test]
1817
async fn test_register_worker() -> anyhow::Result<()> {
1918
println!("Starting test...");
@@ -32,7 +31,7 @@ async fn test_register_worker() -> anyhow::Result<()> {
3231
.await?;
3332
println!("\nResult init: {:?}", result);
3433

35-
//Call register_worker
34+
// Call register_worker
3635
let collateral = include_str!("samples/quote_collateral.json").to_string();
3736
let result = contract
3837
.call("register_worker")

0 commit comments

Comments
 (0)