-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
64 lines (53 loc) · 2.03 KB
/
test.js
File metadata and controls
64 lines (53 loc) · 2.03 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
58
59
60
61
62
63
64
#!/usr/bin/env node
/**
* Quick test script for Nook
*/
const { NookProtocol, SEED_VARIANTS } = require('./index.js');
console.log('🧪 Nook Protocol Test\n');
// Test 1: Create new Nook instance with higher caps for testing
console.log('Test 1: Create Nook instance');
const nook = new NookProtocol({ agentId: 'test-agent' });
nook.sparkEngine.hourlyCap = 1000;
nook.sparkEngine.dailyCap = 10000;
console.log('✅ Created\n');
// Test 2: Initialize sprite
console.log('Test 2: Initialize sprite');
const initResult = nook.init('worker');
console.log(`✅ ${initResult.message}\n`);
// Test 3: Emit events with more tokens and distinct work units
console.log('Test 3: Emit events');
for (let i = 0; i < 10; i++) {
const result = nook.emit({
eventId: `evt-${Date.now()}-${i}`,
eventVersion: '1.0',
type: 'agent.completed',
workUnitId: `task-${Date.now()}-${i}`,
tokens: 50000 + (i * 5000),
success: true,
agentId: nook.agentId,
rootIdentityId: nook.rootIdentity
});
console.log(` Task ${i}: +${result.sparks} sparks (total: ${result.totalSparks})`);
}
console.log('✅ Events emitted\n');
// Test 4: Check status
console.log('Test 4: Status');
const status = nook.getStatus();
console.log(` Variant: ${status.sprite.variant}`);
console.log(` Stage: ${status.sprite.stage}`);
console.log(` Sparks: ${status.sparks}`);
console.log(` Next evolution: ${status.nextEvolution?.name || 'N/A'}\n`);
// Test 5: Test achievements
console.log('Test 5: Track achievement');
const achievements = nook.getAchievements();
achievements.trackEvent('agent.tokens', { tokens: 1500 });
console.log(` Unlocked: ${achievements.getUnlockedAchievements().length}\n`);
// Test 6: Persistence
console.log('Test 6: Persistence');
const profilePath = nook.getProfilePath();
console.log(` Profile saved to: ${profilePath}`);
// Load fresh instance
const nook2 = new NookProtocol({ agentId: 'test-agent' });
const status2 = nook2.getStatus();
console.log(` Loaded: ${status2.initialized ? '✅ Yes' : '❌ No'}\n`);
console.log('✅ All tests passed!');