@@ -109,3 +109,49 @@ func TestAssetConverter_convertAssetPossession(t *testing.T) {
109109 }, converted )
110110
111111}
112+
113+ func TestAssetConverter_convertContractIpo (t * testing.T ) {
114+
115+ id := types .Identity ("TESTIOGXQKYYZEQXOXFSWWAJNYLCDBWFAPNBLNBUZFHDVFMYPJZXGMEEJEGI" )
116+ pubKey , err := id .ToPubKey (false )
117+ assert .NoError (t , err )
118+
119+ source := types.ContractIpo {
120+ ContractIndex : 5 ,
121+ TickNumber : 100 ,
122+ }
123+
124+ // set one bid with a known identity and price
125+ source .PubKeys [0 ] = pubKey
126+ source .Prices [0 ] = 1000
127+
128+ // set another bid at a different index
129+ source .PubKeys [10 ] = pubKey
130+ source .Prices [10 ] = 2000
131+
132+ // index 1 has zero price, should be skipped
133+ source .PubKeys [1 ] = pubKey
134+ source .Prices [1 ] = 0
135+
136+ converted , err := convertContractIpo (source )
137+ assert .NoError (t , err )
138+
139+ assert .Equal (t , uint32 (5 ), converted .ContractIndex )
140+ assert .Equal (t , uint32 (100 ), converted .TickNumber )
141+
142+ // only 2 bids should be present (zero-price skipped)
143+ assert .Len (t , converted .Bids , 2 )
144+
145+ assert .Equal (t , & protobuff.IpoBid {
146+ Identity : "TESTIOGXQKYYZEQXOXFSWWAJNYLCDBWFAPNBLNBUZFHDVFMYPJZXGMEEJEGI" ,
147+ Amount : 1000 ,
148+ }, converted .Bids [0 ])
149+
150+ assert .Equal (t , & protobuff.IpoBid {
151+ Identity : "TESTIOGXQKYYZEQXOXFSWWAJNYLCDBWFAPNBLNBUZFHDVFMYPJZXGMEEJEGI" ,
152+ Amount : 2000 ,
153+ }, converted .Bids [10 ])
154+
155+ // zero-price bid should not be in the map
156+ assert .Nil (t , converted .Bids [1 ])
157+ }
0 commit comments