-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest-phase1.ts
More file actions
55 lines (45 loc) · 2.17 KB
/
Copy pathtest-phase1.ts
File metadata and controls
55 lines (45 loc) · 2.17 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
/**
* Test file for Phase 1 Foundation Setup
* Run this to verify all blockchain infrastructure is working
*/
import { lineraClient, blockchainConfig, checkBlockchainConnection } from '@/lib/linera-client';
import { SnakeContract } from '@/lib/contract-operations';
import { Direction } from '@/lib/types';
import { formatAddress, directionToArrow, isValidGameState } from '@/utils/blockchain-utils';
// Test 1: Configuration
console.log('=== Phase 1 Foundation Test ===\n');
console.log('✅ Test 1: Configuration');
console.log(' Endpoint:', blockchainConfig.endpoint);
console.log(' Chain ID:', formatAddress(blockchainConfig.chainId, 8, 8));
console.log(' App ID:', formatAddress(blockchainConfig.appId, 8, 8));
console.log(' Mock Mode:', blockchainConfig.enableMockWallet);
// Test 2: Types
console.log('\n✅ Test 2: Types');
const testDirection: Direction = Direction.Up;
console.log(' Direction:', testDirection, directionToArrow(testDirection));
// Test 3: Utilities
console.log('\n✅ Test 3: Utilities');
console.log(' Format address:', formatAddress('0x1234567890abcdef1234567890abcdef12345678'));
console.log(' Arrow symbols: ↑', directionToArrow(Direction.Up));
// Test 4: Contract Operations (Mock)
console.log('\n✅ Test 4: Contract Operations');
(async () => {
try {
const result = await SnakeContract.startGame();
console.log(' Start Game:', result.success ? '✅ Success' : '❌ Failed');
const moveResult = await SnakeContract.moveSnake(Direction.Right);
console.log(' Move Snake:', moveResult.success ? '✅ Success' : '❌ Failed');
const stateResult = await SnakeContract.getGameState('mock-player');
console.log(' Get State:', stateResult.success ? '✅ Success' : '❌ Failed');
if (stateResult.data) {
console.log(' - Snake length:', stateResult.data.snake_body.length);
console.log(' - Score:', stateResult.data.score);
console.log(' - Active:', stateResult.data.is_active);
}
console.log('\n🎉 Phase 1 Foundation Setup Complete!');
console.log('All blockchain infrastructure is ready.');
} catch (error) {
console.error('❌ Error during testing:', error);
}
})();
export {};