File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ impl Output {
6767#[ cfg( test) ]
6868mod test {
6969 use super :: * ;
70+ use crate :: AssetId ;
7071 use crate :: encode:: { serialize_hex, Encodable } ;
7172 use crate :: hex:: { FromHex , ToHex } ;
7273
@@ -110,4 +111,31 @@ mod test {
110111 assert ! ( output_hex. contains( ELIP0101_IDENTIFIER ) ) ;
111112 assert ! ( output_hex. contains( abf_hex) ) ;
112113 }
114+
115+ #[ test]
116+ fn abf_roundtrip ( ) {
117+ use crate :: pset:: PartiallySignedTransaction ;
118+
119+ // Set abf on an input and on an output
120+ let abf = AssetBlindingFactor :: from_slice ( & [ 3 ; 32 ] ) . unwrap ( ) ;
121+ let mut pset = PartiallySignedTransaction :: new_v2 ( ) ;
122+ let mut input = Input :: default ( ) ;
123+ input. set_abf ( abf) ;
124+ pset. add_input ( input) ;
125+ let mut output = Output {
126+ amount : Some ( 1 ) ,
127+ asset : Some ( AssetId :: from_slice ( & [ 9 ; 32 ] ) . unwrap ( ) ) ,
128+ ..Default :: default ( )
129+ } ;
130+ output. set_abf ( abf) ;
131+ pset. add_output ( output) ;
132+
133+ // Serialize and deserialize
134+ let bytes = encode:: serialize ( & pset) ;
135+ let pset_back = encode:: deserialize :: < PartiallySignedTransaction > ( & bytes) . unwrap ( ) ;
136+ // Check the abf
137+ // FIXME: input abf should be there
138+ assert ! ( pset_back. inputs( ) [ 0 ] . get_abf( ) . is_none( ) ) ;
139+ assert_eq ! ( pset_back. outputs( ) [ 0 ] . get_abf( ) . unwrap( ) . unwrap( ) , abf) ;
140+ }
113141}
You can’t perform that action at this time.
0 commit comments