-
Notifications
You must be signed in to change notification settings - Fork 294
/
utils_test.js
45 lines (35 loc) · 1.49 KB
/
utils_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
describe('Utils', function() {
describe('Utils.buildChallengeTx', function() {
it('returns challenge which follows SEP0010 spec', function() {
let keypair = StellarSdk.Keypair.random();
const challenge = StellarSdk.Utils.buildChallengeTx(
keypair,
"GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF",
"SDF"
);
const transaction = new StellarSdk.Transaction(challenge);
expect(transaction.sequence).to.eql("0");
expect(transaction.source).to.eql(keypair.publicKey());
expect(transaction.operations.length).to.eql(1);
const { maxTime, minTime } = transaction.timeBounds;
expect(parseInt(maxTime) - parseInt(minTime)).to.eql(300);
const [ operation ] = transaction.operations;
expect(operation.name).to.eql("SDF auth");
expect(operation.source).to.eql("GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF");
expect(operation.type).to.eql("manageData");
expect(operation.value.length).to.eql(64);
});
it('uses the passed-in timeout', function() {
let keypair = StellarSdk.Keypair.random();
const challenge = StellarSdk.Utils.buildChallengeTx(
keypair,
"GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF",
"SDF",
600
);
const transaction = new StellarSdk.Transaction(challenge);
const { maxTime, minTime } = transaction.timeBounds;
expect(parseInt(maxTime) - parseInt(minTime)).to.eql(600);
});
});
});