@@ -1095,7 +1095,11 @@ func TestUtxoValidateCollateralContainsNonAda(t *testing.T) {
1095
1095
testInputTxId := "d228b482a1aae768e4a796380f49e021d9c21f70d3c12cb186b188dedfc0ee22"
1096
1096
var testCollateralAmount uint64 = 100000
1097
1097
testTx := & conway.ConwayTransaction {
1098
- Body : conway.ConwayTransactionBody {},
1098
+ Body : conway.ConwayTransactionBody {
1099
+ BabbageTransactionBody : babbage.BabbageTransactionBody {
1100
+ TxTotalCollateral : testCollateralAmount ,
1101
+ },
1102
+ },
1099
1103
WitnessSet : conway.ConwayTransactionWitnessSet {
1100
1104
WsRedeemers : conway.ConwayRedeemers {
1101
1105
Redeemers : map [conway.ConwayRedeemerKey ]conway.ConwayRedeemerValue {
@@ -1106,7 +1110,11 @@ func TestUtxoValidateCollateralContainsNonAda(t *testing.T) {
1106
1110
},
1107
1111
}
1108
1112
tmpMultiAsset := common.NewMultiAsset [common.MultiAssetTypeOutput ](
1109
- map [common.Blake2b224 ]map [cbor.ByteString ]uint64 {},
1113
+ map [common.Blake2b224 ]map [cbor.ByteString ]uint64 {
1114
+ common .Blake2b224Hash ([]byte ("abcd" )): map [cbor.ByteString ]uint64 {
1115
+ cbor .NewByteString ([]byte ("efgh" )): 123 ,
1116
+ },
1117
+ },
1110
1118
)
1111
1119
testLedgerState := test.MockLedgerState {
1112
1120
MockUtxos : []common.Utxo {
@@ -1181,6 +1189,34 @@ func TestUtxoValidateCollateralContainsNonAda(t *testing.T) {
1181
1189
}
1182
1190
},
1183
1191
)
1192
+ // Coin and assets with return
1193
+ t .Run (
1194
+ "coin and assets with return" ,
1195
+ func (t * testing.T ) {
1196
+ testTx .Body .TxCollateral = []shelley.ShelleyTransactionInput {
1197
+ shelley .NewShelleyTransactionInput (testInputTxId , 0 ),
1198
+ shelley .NewShelleyTransactionInput (testInputTxId , 1 ),
1199
+ }
1200
+ testTx .Body .TxCollateralReturn = & babbage.BabbageTransactionOutput {
1201
+ OutputAmount : mary.MaryTransactionOutputValue {
1202
+ Amount : testCollateralAmount ,
1203
+ Assets : & tmpMultiAsset ,
1204
+ },
1205
+ }
1206
+ err := conway .UtxoValidateCollateralContainsNonAda (
1207
+ testTx ,
1208
+ testSlot ,
1209
+ testLedgerState ,
1210
+ testProtocolParams ,
1211
+ )
1212
+ if err != nil {
1213
+ t .Errorf (
1214
+ "UtxoValidateCollateralContainsNonAda should succeed when collateral with only coin is provided\n got error: %v" ,
1215
+ err ,
1216
+ )
1217
+ }
1218
+ },
1219
+ )
1184
1220
}
1185
1221
1186
1222
func TestUtxoValidateNoCollateralInputs (t * testing.T ) {
0 commit comments