File tree 2 files changed +26
-1
lines changed
src/Serialization/TransactionBody
test/Serialization/TransactionBody
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -990,7 +990,7 @@ export class TransactionBody {
990
990
let mapSize = 0 ;
991
991
992
992
if ( this . #inputs !== undefined && this . #inputs. length > 0 ) ++ mapSize ;
993
- if ( this . #outputs !== undefined && this . #inputs . length > 0 ) ++ mapSize ;
993
+ if ( this . #outputs !== undefined && this . #outputs . length > 0 ) ++ mapSize ;
994
994
if ( this . #fee !== undefined ) ++ mapSize ;
995
995
if ( this . #ttl !== undefined ) ++ mapSize ;
996
996
if ( this . #certs !== undefined && this . #certs. length > 0 ) ++ mapSize ;
Original file line number Diff line number Diff line change @@ -65,6 +65,23 @@ export const core: Cardano.TxBody = {
65
65
]
66
66
} ;
67
67
68
+ export const noInputsCore : Cardano . TxBody = {
69
+ certificates : [
70
+ {
71
+ __typename : Cardano . CertificateType . PoolRetirement ,
72
+ epoch : Cardano . EpochNo ( 500 ) ,
73
+ poolId : Cardano . PoolId ( 'pool1y6chk7x7fup4ms9leesdr57r4qy9cwxuee0msan72x976a6u0nc' )
74
+ }
75
+ ] ,
76
+ fee : 10n ,
77
+ inputs : [ ] ,
78
+ outputs : [ txOut ]
79
+ } ;
80
+
81
+ export const noInputsCbor = HexBlob (
82
+ 'a30181825839009493315cd92eb5d8c4304e67b7e16ae36d61d34502694657811a2c8e32c728d3861e164cab28cb8f006448139c8f1740ffb8e7aa9e5232dc820aa3581c2a286ad895d091f2b3d168a6091ad2627d30a72761a5bc36eef00740a14014581c659f2917fb63f12b33667463ee575eeac1845bbc736b9c0bbc40ba82a14454534c411832581c7eae28af2208be856f7a119668ae52a49b73725e326dc16579dcc373a240182846504154415445181e020a04818304581c26b17b78de4f035dc0bfce60d1d3c3a8085c38dcce5fb8767e518bed1901f4'
83
+ ) ;
84
+
68
85
export const conwayCore : Cardano . TxBody = {
69
86
...core ,
70
87
donation : 1000n ,
@@ -239,4 +256,12 @@ describe('TransactionBody', () => {
239
256
240
257
expect ( withdrawals ) . toEqual ( expectedWithdrawals ) ;
241
258
} ) ;
259
+
260
+ it ( 'can encode transaction bodies with 0 inputs correctly' , ( ) => {
261
+ const bodyFromCbor = TransactionBody . fromCbor ( noInputsCbor ) ;
262
+ const bodyFromCore = TransactionBody . fromCore ( noInputsCore ) ;
263
+
264
+ expect ( bodyFromCbor . toCore ( ) ) . toEqual ( noInputsCore ) ;
265
+ expect ( bodyFromCore . toCbor ( ) ) . toEqual ( noInputsCbor ) ;
266
+ } ) ;
242
267
} ) ;
You can’t perform that action at this time.
0 commit comments