-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-blockchain-only.js
More file actions
57 lines (47 loc) Β· 2.11 KB
/
test-blockchain-only.js
File metadata and controls
57 lines (47 loc) Β· 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const axios = require("axios");
async function testBlockchainOnlyFlow() {
console.log("π Testing Pure Blockchain Order Acceptance");
console.log("==========================================");
const API_BASE_URL = "http://localhost:5001/api";
// Test with a known blockchain order ID that the resolver detected
const blockchainOrderId =
"0x3a3d6ac3379a4fd4f15776162dc0f3f2377d842883f91909e7d468175c489f7a";
const acceptedPrice = "84404126514302625792"; // Wei format price from resolver
const resolverAddress = "0xb862825240fC768515A26D09FAeB9Ab3236Df09e";
console.log(`π Order ID: ${blockchainOrderId}`);
console.log(`π° Accepted Price: ${acceptedPrice} (wei format)`);
console.log(`π€ Resolver: ${resolverAddress}`);
try {
console.log("\nπ€ Attempting to accept blockchain order...");
const response = await axios.post(
`${API_BASE_URL}/orders/${blockchainOrderId}/accept`,
{
acceptedPrice: acceptedPrice,
resolverAddress: resolverAddress,
}
);
console.log("β
SUCCESS! Order accepted via pure blockchain flow");
console.log(` Response: ${response.data.message}`);
console.log(
` Transaction Hash: ${
response.data.data?.transactionHash || "N/A"
}`
);
} catch (error) {
console.error("β FAILED to accept blockchain order");
console.error(` Status: ${error.response?.status}`);
console.error(
` Error: ${error.response?.data?.message || error.message}`
);
if (error.response?.data?.error) {
console.error(` Type: ${error.response.data.error}`);
}
}
console.log("\nπ― Expected Result:");
console.log(" β
Backend reads order from blockchain (no database)");
console.log(" β
Price validation passes");
console.log(" β
Smart contract call succeeds");
console.log(" β
Transaction hash returned");
console.log(" β
No database dependencies");
}
testBlockchainOnlyFlow().catch(console.error);