mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 20:25:48 +00:00
Add unit test for offline prepare and sign
This commit is contained in:
@@ -4,6 +4,7 @@ const _ = require('lodash');
|
||||
const assert = require('assert-diff');
|
||||
const path = require('path');
|
||||
const setupAPI = require('./setup-api');
|
||||
const RippleAPI = require('../src').RippleAPI;
|
||||
const fixtures = require('./fixtures/api');
|
||||
const requests = fixtures.requests;
|
||||
const responses = fixtures.responses;
|
||||
@@ -737,3 +738,27 @@ describe('RippleAPI', function() {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('RippleAPI - offline', function() {
|
||||
it('prepareSettings and sign', function(done) {
|
||||
const api = new RippleAPI();
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV';
|
||||
const settings = requests.prepareSettings;
|
||||
const instructions = {
|
||||
sequence: 23,
|
||||
maxLedgerVersion: 8820051,
|
||||
fee: '0.000012'
|
||||
};
|
||||
api.prepareSettings(address, settings, instructions, (error, txJSON) => {
|
||||
if (error) {
|
||||
done(error);
|
||||
return;
|
||||
}
|
||||
assert.deepEqual(txJSON, responses.prepareSettings.flags);
|
||||
withDeterministicPRNG(() => {
|
||||
assert.deepEqual(api.sign(txJSON, secret), responses.sign);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
4
test/fixtures/api/requests/sign.json
vendored
4
test/fixtures/api/requests/sign.json
vendored
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"Flags": 0,
|
||||
"TransactionType": "AccountSet",
|
||||
"Account": "r3GgMwvgvP8h4yVWvjH1dPZNvC37TjzBBE",
|
||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"Domain": "726970706C652E636F6D",
|
||||
"LastLedgerSequence": 8820052,
|
||||
"LastLedgerSequence": 8820051,
|
||||
"Fee": "12",
|
||||
"Sequence": 23
|
||||
}
|
||||
|
||||
4
test/fixtures/api/responses/prepare-settings-signed.json
vendored
Normal file
4
test/fixtures/api/responses/prepare-settings-signed.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"signedTransaction": "12000322000000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402207660BDEF67105CE1EBA9AD35DC7156BAB43FF1D47633199EE257D70B6B9AAFBF022045A812486A675750B5A3F37131E9F92299728D37FF6BB7195CA5EE881268CB4C770A726970706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304",
|
||||
"id": "29D23159EBA79170DCA5EF467CBC15114DBD35B7A8C3DBF76809BA354D00D250"
|
||||
}
|
||||
4
test/fixtures/api/responses/sign.json
vendored
4
test/fixtures/api/responses/sign.json
vendored
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"signedTransaction": "12000322000000002400000017201B0086955468400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402207660BDEF67105CE1EBA9AD35DC7156BAB43FF1D47633199EE257D70B6B9AAFBF02207F5517BC8AEF2ADC1325897ECDBA8C673838048BCA62F4E98B252F19BE88796D770A726970706C652E636F6D81144FBFF73DA4ECF9B701940F27341FA8020C313443",
|
||||
"id": "DB44C111583A95AF973A0B0A40348D90512FCBCDDCA3315A286D2BF4FAC100F1"
|
||||
"signedTransaction": "12000322000000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402207660BDEF67105CE1EBA9AD35DC7156BAB43FF1D47633199EE257D70B6B9AAFBF022045A812486A675750B5A3F37131E9F92299728D37FF6BB7195CA5EE881268CB4C770A726970706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304",
|
||||
"id": "29D23159EBA79170DCA5EF467CBC15114DBD35B7A8C3DBF76809BA354D00D250"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user