-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
66 lines (52 loc) · 1.37 KB
/
test.js
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
65
66
import Store from "./index.js";
// test
// let a = new Store({type:"logs",simulation:"sim-123"});
let s = new Store({type:"simulations"});
// console.log(s);
// console.log("sadsad",s);
let i = 0, stop = 1000;
testLoop();
async function testLoop(){
console.log("saving",i);
await test(i++);
if(i>=stop){return}
setTimeout(testLoop,1000)
// await a.cleanUp({simulation:"123"});
};
async function test(i) {
// await save(a, [
// {day:i,message: "foo"},
// {day:i,message: "bar"},
// ]);
await save(s, {id:i+"-stuff", day:i,message:"lots of stuff"});
// let agentLogs = await read(a);
// console.log("agent logs",agentLogs);
// let simLogs = await read(s);
// console.log("simulation details",simLogs);
// await s.cleanUp();
}
async function save(s,doc){
return new Promise((resolve,reject)=>{
s.save(doc)
.then(val=>{
// console.log(val);
resolve(val);
})
.catch(err=>{
console.error(err);
reject(err);
});
});
}
async function read(s){
return new Promise((resolve,reject)=>{
s.read()
.then(val=>{
resolve(val);
})
.catch(err=>{
console.error(err);
reject(err);
});
});
}