File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-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,29 @@ 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 :: default ( ) ;
126+ output. amount = Some ( 1 ) ;
127+ output. asset = Some ( AssetId :: from_slice ( & [ 9 ; 32 ] ) . unwrap ( ) ) ;
128+ output. set_abf ( abf) ;
129+ pset. add_output ( output) ;
130+
131+ // Serialize and deserialize
132+ let bytes = encode:: serialize ( & pset) ;
133+ let pset_back = encode:: deserialize :: < PartiallySignedTransaction > ( & bytes) . unwrap ( ) ;
134+ // Check the abf
135+ // FIXME: input abf should be there
136+ assert ! ( pset_back. inputs( ) [ 0 ] . get_abf( ) . is_none( ) ) ;
137+ assert_eq ! ( pset_back. outputs( ) [ 0 ] . get_abf( ) . unwrap( ) . unwrap( ) , abf) ;
138+ }
113139}
You can’t perform that action at this time.
0 commit comments