@@ -1107,7 +1107,11 @@ func TestUtxoValidateCollateralContainsNonAda(t *testing.T) {
1107
1107
testInputTxId := "d228b482a1aae768e4a796380f49e021d9c21f70d3c12cb186b188dedfc0ee22"
1108
1108
var testCollateralAmount uint64 = 100000
1109
1109
testTx := & conway.ConwayTransaction {
1110
- Body : conway.ConwayTransactionBody {},
1110
+ Body : conway.ConwayTransactionBody {
1111
+ BabbageTransactionBody : babbage.BabbageTransactionBody {
1112
+ TxTotalCollateral : testCollateralAmount ,
1113
+ },
1114
+ },
1111
1115
WitnessSet : conway.ConwayTransactionWitnessSet {
1112
1116
WsRedeemers : conway.ConwayRedeemers {
1113
1117
Redeemers : map [conway.ConwayRedeemerKey ]conway.ConwayRedeemerValue {
@@ -1118,7 +1122,11 @@ func TestUtxoValidateCollateralContainsNonAda(t *testing.T) {
1118
1122
},
1119
1123
}
1120
1124
tmpMultiAsset := common.NewMultiAsset [common.MultiAssetTypeOutput ](
1121
- map [common.Blake2b224 ]map [cbor.ByteString ]uint64 {},
1125
+ map [common.Blake2b224 ]map [cbor.ByteString ]uint64 {
1126
+ common .Blake2b224Hash ([]byte ("abcd" )): map [cbor.ByteString ]uint64 {
1127
+ cbor .NewByteString ([]byte ("efgh" )): 123 ,
1128
+ },
1129
+ },
1122
1130
)
1123
1131
testLedgerState := test.MockLedgerState {
1124
1132
MockUtxos : []common.Utxo {
@@ -1193,6 +1201,34 @@ func TestUtxoValidateCollateralContainsNonAda(t *testing.T) {
1193
1201
}
1194
1202
},
1195
1203
)
1204
+ // Coin and assets with return
1205
+ t .Run (
1206
+ "coin and assets with return" ,
1207
+ func (t * testing.T ) {
1208
+ testTx .Body .TxCollateral = []shelley.ShelleyTransactionInput {
1209
+ shelley .NewShelleyTransactionInput (testInputTxId , 0 ),
1210
+ shelley .NewShelleyTransactionInput (testInputTxId , 1 ),
1211
+ }
1212
+ testTx .Body .TxCollateralReturn = & babbage.BabbageTransactionOutput {
1213
+ OutputAmount : mary.MaryTransactionOutputValue {
1214
+ Amount : testCollateralAmount ,
1215
+ Assets : & tmpMultiAsset ,
1216
+ },
1217
+ }
1218
+ err := conway .UtxoValidateCollateralContainsNonAda (
1219
+ testTx ,
1220
+ testSlot ,
1221
+ testLedgerState ,
1222
+ testProtocolParams ,
1223
+ )
1224
+ if err != nil {
1225
+ t .Errorf (
1226
+ "UtxoValidateCollateralContainsNonAda should succeed when collateral with only coin is provided\n got error: %v" ,
1227
+ err ,
1228
+ )
1229
+ }
1230
+ },
1231
+ )
1196
1232
}
1197
1233
1198
1234
func TestUtxoValidateNoCollateralInputs (t * testing.T ) {
0 commit comments