-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
47 lines (43 loc) · 1.15 KB
/
index.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
import Fungus from './index';
const fungus = new Fungus({
lotionUrl: 'http://localhost:3000' // Ensure lotion is running on port 3000
})
function user(n){
return new Promise((resolve, reject)=>{
const temWalletObj = {};
temWalletObj.privateKey = fungus.generateStaticPrivateKey(n);
temWalletObj.address = fungus.generateAddress(temWalletObj.privateKey);
fungus.getBalance(temWalletObj.address).then(b=>{
temWalletObj.balance = b;
resolve(temWalletObj)
}).catch(err=>{
console.error(err);
reject(err);
})
})
}
describe('Fungus', () => {
let userOne, userTwo;
it('can createTransaction', (done) => {
user(1).then(w=>{
userOne=w
console.log(userOne.address.toString('hex'))
user(2).then(w=>{
userTwo=w
fungus.createTransaction(
userOne.privateKey, {
address: userTwo.address,
amount: 10,
feePortion: 0.50,
org: ['celadon_wallet', 'impacthub_wallet']
}).then(good=>{
expect(good.result).not.toBeNull()
done()
})
.catch(err=>{
console.error(err);
})
})
})
});
});