Skip to content

Commit a4fa125

Browse files
wli-proBillyWooo
andauthored
feat: P-1724 add integration test for omni_getHyperliquidSignatureData (#3751)
* feat: P-1724 add integration test for omni_getHyperliquidSignatureData * fix build error --------- Co-authored-by: wli-pro <wli-pro> Co-authored-by: BillyWooo <yang@trustcomputing.de>
1 parent e2eac0f commit a4fa125

File tree

10 files changed

+879
-1
lines changed

10 files changed

+879
-1
lines changed

tee-worker/omni-executor/Cargo.lock

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

tee-worker/omni-executor/cli/ts_jsonrpc_mock_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ cd /ts-tests
2929
pnpm install --force
3030

3131
echo "Running JSON-RPC tests"
32-
OMNI_WORKER_ENDPOINT=http://omni-executor:2100 pnpm --filter jsonrpc-mock-tests test jsonrpc_mock_test.test.ts
32+
OMNI_WORKER_ENDPOINT=http://omni-executor:2100 pnpm --filter jsonrpc-mock-tests test jsonrpc_mock_test.test.ts hyperliquid_signature_data.test.ts
3333

3434
echo "JSON-RPC tests completed successfully"

tee-worker/omni-executor/mock-server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ alloy = { workspace = true, features = ["node-bindings", "json-rpc"] }
88
hex = { workspace = true, features = ["std"] }
99
libsecp256k1 = { workspace = true }
1010
log = { workspace = true, features = ["std"] }
11+
serde = { workspace = true }
1112
serde_json = { workspace = true, features = ["std"] }
1213
sp-core = { workspace = true, features = ["std"] }
1314
tokio = { workspace = true, features = ["full"] }

tee-worker/omni-executor/mock-server/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ mod evm;
1717
mod pumpx;
1818
mod sendgrid;
1919
mod solana;
20+
mod wildmeta;
2021

2122
// It should only works on UNIX.
2223
async fn shutdown_signal() {
@@ -56,6 +57,7 @@ pub fn run_with_shutdown_control(
5657
.or(pumpx::handle())
5758
.or(sendgrid::handle())
5859
.or(solana::handle())
60+
.or(wildmeta::handle())
5961
.boxed(),
6062
)
6163
.bind_with_graceful_shutdown(([0, 0, 0, 0], port), async {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#![allow(opaque_hidden_inferred_bound)]
2+
3+
use serde::{Deserialize, Serialize};
4+
use warp::{http::Response, Filter};
5+
6+
const BASE_PATH: &str = "wildmeta";
7+
8+
#[derive(Serialize, Deserialize)]
9+
struct HyperliquidLinkRequest {
10+
main_address: String,
11+
agent_address: String,
12+
login_type: i32,
13+
}
14+
15+
#[derive(Serialize, Deserialize)]
16+
#[serde(rename_all = "camelCase")]
17+
struct HyperliquidLinkResponseData {
18+
is_bound: bool,
19+
}
20+
21+
#[derive(Serialize, Deserialize)]
22+
struct ApiResponse<T> {
23+
code: i32,
24+
message: String,
25+
data: T,
26+
}
27+
28+
pub(crate) fn handle() -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone
29+
{
30+
warp::post()
31+
.and(warp::path(BASE_PATH))
32+
.and(warp::path!("v1" / "account" / "check_hyper_agent_address"))
33+
.and(warp::body::json())
34+
.map(|_request: HyperliquidLinkRequest| {
35+
let response_data = HyperliquidLinkResponseData {
36+
is_bound: true, // Always return true for testing
37+
};
38+
39+
let api_response =
40+
ApiResponse { code: 200, message: "Success".to_string(), data: response_data };
41+
42+
Response::builder()
43+
.status(200)
44+
.header("content-type", "application/json")
45+
.body(serde_json::to_string(&api_response).unwrap())
46+
.unwrap()
47+
})
48+
}

0 commit comments

Comments
 (0)