-
Notifications
You must be signed in to change notification settings - Fork 302
Expand file tree
/
Copy pathexplainTransaction.test.ts
More file actions
51 lines (40 loc) · 1.68 KB
/
explainTransaction.test.ts
File metadata and controls
51 lines (40 loc) · 1.68 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
import { BitGoAPI } from '@bitgo/sdk-api';
import { Hteth } from '@bitgo/sdk-coin-eth';
import * as should from 'should';
describe('AbstractEthLikeCoin explainTransaction', function () {
let bitgo: BitGoAPI;
let hteth;
before(function () {
bitgo = new BitGoAPI({ env: 'test' });
bitgo.register('hteth', Hteth.createInstance);
hteth = bitgo.coin('hteth');
});
it('should explain a SingleSigSend transaction and return outputs', async function () {
const txHex =
'02f483088bb080830d4ae184012759d5830178749477aafabf1b7155f00292acf2be008e8fc9ef7b3a87038d7ea4c6800080c0808080';
const feeInfo = { fee: '974670461244' };
const explanation = await hteth.explainTransaction({
txHex,
feeInfo,
});
// Assertions to verify the bug is fixed
should.exist(explanation);
should.exist(explanation.id);
explanation.id.should.equal('0x84270a6ec4defc63ff8f37d4e1c5195e6772c634b89450864ecd5e6a8360b2d3');
should.exist(explanation.outputs);
explanation.outputs.should.be.an.Array();
explanation.outputs.length.should.equal(1, 'Should have exactly 1 output');
// Verify output details
const output = explanation.outputs[0];
output.address.should.equal('0x77aafabf1b7155f00292acf2be008e8fc9ef7b3a');
output.amount.should.equal('1000000000000000'); // 0.001 ETH
// Verify output amount
explanation.outputAmount.should.equal('1000000000000000');
// Verify change outputs (should be empty for ETH)
explanation.changeOutputs.should.be.an.Array();
explanation.changeOutputs.length.should.equal(0);
explanation.changeAmount.should.equal('0');
// Verify fee
explanation.fee.should.equal(feeInfo);
});
});