-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-contracts.js
More file actions
42 lines (34 loc) · 1.37 KB
/
test-contracts.js
File metadata and controls
42 lines (34 loc) · 1.37 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
// Test script for Cadence contracts
import { FlowSwapClient } from './src/bindings/flow-bindings.ts';
async function testContracts() {
console.log('🧪 Testing Cadence Contracts...\n');
const client = new FlowSwapClient();
try {
// Test 1: Get Pool Info
console.log('📊 Testing Pool Info...');
const poolInfo = await client.getPoolInfo();
console.log('Pool Info:', poolInfo);
console.log('✅ Pool info test passed\n');
// Test 2: Get LP Balance (with test address)
console.log('💰 Testing LP Balance...');
const testAddress = '0x0c0c904844c9a720'; // Contract address for testing
const lpBalance = await client.getLPBalance(testAddress);
console.log('LP Balance:', lpBalance);
console.log('✅ LP balance test passed\n');
console.log('🎉 All contract tests passed!');
} catch (error) {
console.error('❌ Contract test failed:', error);
// Detailed error analysis
if (error.message.includes('FlowSwap')) {
console.log('💡 Suggestion: Make sure FlowSwap contract is deployed');
}
if (error.message.includes('getFlowReserve')) {
console.log('💡 Suggestion: Check if pool functions exist in contract');
}
if (error.message.includes('capabilities')) {
console.log('💡 Suggestion: Check capability setup in contract');
}
}
}
// Run tests
testContracts();