diff --git a/ledger/allegra/pparams_test.go b/ledger/allegra/pparams_test.go index 0ac58790..c84bb3b9 100644 --- a/ledger/allegra/pparams_test.go +++ b/ledger/allegra/pparams_test.go @@ -134,8 +134,13 @@ func TestAllegraUtxorpc(t *testing.T) { // Unit test for AllegraTransactionBody.Utxorpc() func TestAllegraTransactionBody_Utxorpc(t *testing.T) { // mock input - input := shelley.NewShelleyTransactionInput("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 1) - inputSet := shelley.NewShelleyTransactionInputSet([]shelley.ShelleyTransactionInput{input}) + input := shelley.NewShelleyTransactionInput( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + 1, + ) + inputSet := shelley.NewShelleyTransactionInputSet( + []shelley.ShelleyTransactionInput{input}, + ) address := common.Address{} @@ -159,23 +164,40 @@ func TestAllegraTransactionBody_Utxorpc(t *testing.T) { // Check that the fee matches if actual.Fee != txBody.Fee() { - t.Errorf("AllegraTransactionBody.Utxorpc() fee mismatch\nGot: %d\nWant: %d", actual.Fee, txBody.Fee()) + t.Errorf( + "AllegraTransactionBody.Utxorpc() fee mismatch\nGot: %d\nWant: %d", + actual.Fee, + txBody.Fee(), + ) } // Check number of inputs if len(actual.Inputs) != len(txBody.Inputs()) { - t.Errorf("AllegraTransactionBody.Utxorpc() input length mismatch\nGot: %d\nWant: %d", len(actual.Inputs), len(txBody.Inputs())) + t.Errorf( + "AllegraTransactionBody.Utxorpc() input length mismatch\nGot: %d\nWant: %d", + len(actual.Inputs), + len(txBody.Inputs()), + ) } // Check number of outputs if len(actual.Outputs) != len(txBody.Outputs()) { - t.Errorf("AllegraTransactionBody.Utxorpc() output length mismatch\nGot: %d\nWant: %d", len(actual.Outputs), len(txBody.Outputs())) + t.Errorf( + "AllegraTransactionBody.Utxorpc() output length mismatch\nGot: %d\nWant: %d", + len(actual.Outputs), + len(txBody.Outputs()), + ) } } // Unit test for AllegraTransaction.Utxorpc() func TestAllegraTransaction_Utxorpc(t *testing.T) { // Prepare mock input - input := shelley.NewShelleyTransactionInput("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", 0) - inputSet := shelley.NewShelleyTransactionInputSet([]shelley.ShelleyTransactionInput{input}) + input := shelley.NewShelleyTransactionInput( + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + 0, + ) + inputSet := shelley.NewShelleyTransactionInputSet( + []shelley.ShelleyTransactionInput{input}, + ) // Prepare mock output address := common.Address{} @@ -202,14 +224,26 @@ func TestAllegraTransaction_Utxorpc(t *testing.T) { // Assertion checks if actual.Fee != tx.Fee() { - t.Errorf("AllegraTransaction.Utxorpc() fee mismatch\nGot: %d\nWant: %d", actual.Fee, tx.Fee()) + t.Errorf( + "AllegraTransaction.Utxorpc() fee mismatch\nGot: %d\nWant: %d", + actual.Fee, + tx.Fee(), + ) } if len(actual.Inputs) != len(tx.Inputs()) { - t.Errorf("AllegraTransaction.Utxorpc() input length mismatch\nGot: %d\nWant: %d", len(actual.Inputs), len(tx.Inputs())) + t.Errorf( + "AllegraTransaction.Utxorpc() input length mismatch\nGot: %d\nWant: %d", + len(actual.Inputs), + len(tx.Inputs()), + ) } if len(actual.Outputs) != len(tx.Outputs()) { - t.Errorf("AllegraTransaction.Utxorpc() output length mismatch\nGot: %d\nWant: %d", len(actual.Outputs), len(tx.Outputs())) + t.Errorf( + "AllegraTransaction.Utxorpc() output length mismatch\nGot: %d\nWant: %d", + len(actual.Outputs), + len(tx.Outputs()), + ) } } diff --git a/ledger/alonzo/pparams_test.go b/ledger/alonzo/pparams_test.go index 220e4bdb..cc46a018 100644 --- a/ledger/alonzo/pparams_test.go +++ b/ledger/alonzo/pparams_test.go @@ -477,15 +477,24 @@ func TestAlonzoTransactionOutput_Utxorpc(t *testing.T) { } if !reflect.DeepEqual(got, want) { - t.Errorf("AlonzoTransactionOutput.Utxorpc() mismatch\nGot: %+v\nWant: %+v", got, want) + t.Errorf( + "AlonzoTransactionOutput.Utxorpc() mismatch\nGot: %+v\nWant: %+v", + got, + want, + ) } } // Unit test for AlonzoTransactionBody.Utxorpc() func TestAlonzoTransactionBody_Utxorpc(t *testing.T) { // Mock input - input := shelley.NewShelleyTransactionInput("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0) - inputSet := shelley.NewShelleyTransactionInputSet([]shelley.ShelleyTransactionInput{input}) + input := shelley.NewShelleyTransactionInput( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + 0, + ) + inputSet := shelley.NewShelleyTransactionInputSet( + []shelley.ShelleyTransactionInput{input}, + ) // Mock output address := common.Address{} @@ -513,7 +522,11 @@ func TestAlonzoTransactionBody_Utxorpc(t *testing.T) { t.Errorf("Expected 1 input, got %d", len(got.Inputs)) } if got.Inputs[0].OutputIndex != input.Index() { - t.Errorf("Input index mismatch: got %d, want %d", got.Inputs[0].OutputIndex, input.Index()) + t.Errorf( + "Input index mismatch: got %d, want %d", + got.Inputs[0].OutputIndex, + input.Index(), + ) } if len(got.Outputs) != 1 { t.Errorf("Expected 1 output, got %d", len(got.Outputs)) @@ -529,8 +542,13 @@ func TestAlonzoTransactionBody_Utxorpc(t *testing.T) { // Unit test for AlonzoTransaction.Utxorpc() func TestAlonzoTransaction_Utxorpc(t *testing.T) { // Mock input - input := shelley.NewShelleyTransactionInput("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", 1) - inputSet := shelley.NewShelleyTransactionInputSet([]shelley.ShelleyTransactionInput{input}) + input := shelley.NewShelleyTransactionInput( + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + 1, + ) + inputSet := shelley.NewShelleyTransactionInputSet( + []shelley.ShelleyTransactionInput{input}, + ) // Mock output address := common.Address{} @@ -571,7 +589,11 @@ func TestAlonzoTransaction_Utxorpc(t *testing.T) { } expectedDatum := datumHash.Bytes() if !reflect.DeepEqual(got.Outputs[0].Datum.Hash, expectedDatum) { - t.Errorf("Datum hash mismatch: got %x, want %x", got.Outputs[0].Datum.Hash, expectedDatum) + t.Errorf( + "Datum hash mismatch: got %x, want %x", + got.Outputs[0].Datum.Hash, + expectedDatum, + ) } if len(got.Hash) == 0 { t.Error("Expected non-empty transaction hash") diff --git a/ledger/babbage/pparams_test.go b/ledger/babbage/pparams_test.go index 6015f83b..7119c8d4 100644 --- a/ledger/babbage/pparams_test.go +++ b/ledger/babbage/pparams_test.go @@ -558,7 +558,10 @@ func TestBabbageUtxorpc(t *testing.T) { // Unit test for BabbageTransactionInput.Utxorpc() func TestBabbageTransactionInput_Utxorpc(t *testing.T) { - input := shelley.NewShelleyTransactionInput("cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", 2) + input := shelley.NewShelleyTransactionInput( + "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + 2, + ) got := input.Utxorpc() want := &cardano.TxInput{ @@ -567,7 +570,11 @@ func TestBabbageTransactionInput_Utxorpc(t *testing.T) { } if !reflect.DeepEqual(got, want) { - t.Errorf("BabbageTransactionInput.Utxorpc() mismatch\\nGot: %+v\\nWant: %+v", got, want) + t.Errorf( + "BabbageTransactionInput.Utxorpc() mismatch\\nGot: %+v\\nWant: %+v", + got, + want, + ) } } @@ -594,7 +601,11 @@ func TestBabbageTransactionOutput_Utxorpc(t *testing.T) { } if !reflect.DeepEqual(got, want) { - t.Errorf("BabbageTransactionOutput.Utxorpc() mismatch\nGot: %+v\nWant: %+v", got, want) + t.Errorf( + "BabbageTransactionOutput.Utxorpc() mismatch\nGot: %+v\nWant: %+v", + got, + want, + ) } } @@ -602,7 +613,9 @@ func TestBabbageTransactionOutput_Utxorpc(t *testing.T) { func TestBabbageTransactionBody_Utxorpc(t *testing.T) { input := shelley.NewShelleyTransactionInput( "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", 1) - inputSet := shelley.NewShelleyTransactionInputSet([]shelley.ShelleyTransactionInput{input}) + inputSet := shelley.NewShelleyTransactionInputSet( + []shelley.ShelleyTransactionInput{input}, + ) address := common.Address{} output := babbage.BabbageTransactionOutput{ @@ -639,7 +652,9 @@ func TestBabbageTransactionBody_Utxorpc(t *testing.T) { func TestBabbageTransaction_Utxorpc(t *testing.T) { input := shelley.NewShelleyTransactionInput( "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", 2) - inputSet := shelley.NewShelleyTransactionInputSet([]shelley.ShelleyTransactionInput{input}) + inputSet := shelley.NewShelleyTransactionInputSet( + []shelley.ShelleyTransactionInput{input}, + ) address := common.Address{} output := babbage.BabbageTransactionOutput{ diff --git a/ledger/babbage/rules_test.go b/ledger/babbage/rules_test.go index 6606ab18..3119d0b8 100644 --- a/ledger/babbage/rules_test.go +++ b/ledger/babbage/rules_test.go @@ -1450,26 +1450,32 @@ func TestUtxoValidateCollateralEqBalance(t *testing.T) { }, ) // no valid collateral UTxO, should skip and not underflow - t.Run("no valid collateral UTxO, should skip and not underflow", func(t *testing.T) { - // Ledger state with NO matching UTxO - missingUtxoLedgerState := test.MockLedgerState{ - MockUtxos: []common.Utxo{}, // empty - } - testTx.Body.TxCollateralReturn = &babbage.BabbageTransactionOutput{ - OutputAmount: mary.MaryTransactionOutputValue{ - Amount: testCollateralReturnAmountBad, - }, - } - err := babbage.UtxoValidateCollateralEqBalance( - testTx, - testSlot, - missingUtxoLedgerState, - testProtocolParams, - ) - if err != nil { - t.Errorf("Should skip collateral return validation if collBalance == 0. Got error: %v", err) - } - }) + t.Run( + "no valid collateral UTxO, should skip and not underflow", + func(t *testing.T) { + // Ledger state with NO matching UTxO + missingUtxoLedgerState := test.MockLedgerState{ + MockUtxos: []common.Utxo{}, // empty + } + testTx.Body.TxCollateralReturn = &babbage.BabbageTransactionOutput{ + OutputAmount: mary.MaryTransactionOutputValue{ + Amount: testCollateralReturnAmountBad, + }, + } + err := babbage.UtxoValidateCollateralEqBalance( + testTx, + testSlot, + missingUtxoLedgerState, + testProtocolParams, + ) + if err != nil { + t.Errorf( + "Should skip collateral return validation if collBalance == 0. Got error: %v", + err, + ) + } + }, + ) } func TestUtxoValidateTooManyCollateralInputs(t *testing.T) { diff --git a/ledger/byron/byron_test.go b/ledger/byron/byron_test.go index f801becd..daeb724a 100644 --- a/ledger/byron/byron_test.go +++ b/ledger/byron/byron_test.go @@ -26,7 +26,10 @@ import ( // Unit test for ByronTransactionInput.Utxorpc() func TestByronTransactionInput_Utxorpc(t *testing.T) { - input := byron.NewByronTransactionInput("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 1) + input := byron.NewByronTransactionInput( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + 1, + ) got := input.Utxorpc() want := &cardano.TxInput{ @@ -35,7 +38,11 @@ func TestByronTransactionInput_Utxorpc(t *testing.T) { } if !reflect.DeepEqual(got, want) { - t.Errorf("ByronTransactionInput.Utxorpc() mismatch\nGot: %+v\nWant: %+v", got, want) + t.Errorf( + "ByronTransactionInput.Utxorpc() mismatch\nGot: %+v\nWant: %+v", + got, + want, + ) } } @@ -57,7 +64,11 @@ func TestByronTransactionOutput_Utxorpc(t *testing.T) { } if !reflect.DeepEqual(got, want) { - t.Errorf("ByronTransactionOutput.Utxorpc() mismatch\nGot: %+v\nWant: %+v", got, want) + t.Errorf( + "ByronTransactionOutput.Utxorpc() mismatch\nGot: %+v\nWant: %+v", + got, + want, + ) } } @@ -71,7 +82,9 @@ func TestByronTransaction_Utxorpc_Empty(t *testing.T) { // Validate it's not nil if result == nil { - t.Fatal("ByronTransaction.Utxorpc() returned nil; expected empty cardano.Tx object") + t.Fatal( + "ByronTransaction.Utxorpc() returned nil; expected empty cardano.Tx object", + ) } // Validate that it's the zero value diff --git a/ledger/common/address.go b/ledger/common/address.go index 1e5fd8c1..a6d2ba31 100644 --- a/ledger/common/address.go +++ b/ledger/common/address.go @@ -389,7 +389,10 @@ func (a Address) Bytes() ([]byte, error) { } rawPayload, err := cbor.Encode(tmpPayload) if err != nil { - return nil, fmt.Errorf("failed to encode Byron address payload: %w", err) + return nil, fmt.Errorf( + "failed to encode Byron address payload: %w", + err, + ) } tmpData := []any{ cbor.Tag{ @@ -400,7 +403,10 @@ func (a Address) Bytes() ([]byte, error) { } ret, err := cbor.Encode(tmpData) if err != nil { - return nil, fmt.Errorf("failed to encode Byron address data: %w", err) + return nil, fmt.Errorf( + "failed to encode Byron address data: %w", + err, + ) } return ret, nil } diff --git a/ledger/conway/pparams.go b/ledger/conway/pparams.go index 643f0cdf..e7d9068d 100644 --- a/ledger/conway/pparams.go +++ b/ledger/conway/pparams.go @@ -239,7 +239,9 @@ func (p *ConwayProtocolParameters) Update( } } -func (p *ConwayProtocolParameters) UpdateFromGenesis(genesis *ConwayGenesis) error { +func (p *ConwayProtocolParameters) UpdateFromGenesis( + genesis *ConwayGenesis, +) error { if genesis == nil { return nil } diff --git a/ledger/conway/pparams_test.go b/ledger/conway/pparams_test.go index 508ac218..8ace192a 100644 --- a/ledger/conway/pparams_test.go +++ b/ledger/conway/pparams_test.go @@ -604,7 +604,10 @@ func TestUtxorpc(t *testing.T) { // Unit test for ConwayTransactionBody.Utxorpc() func TestConwayTransactionBody_Utxorpc(t *testing.T) { - input := shelley.NewShelleyTransactionInput("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 1) + input := shelley.NewShelleyTransactionInput( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + 1, + ) var inputSet conway.ConwayTransactionInputSet inputSet.SetItems([]shelley.ShelleyTransactionInput{input}) @@ -660,7 +663,10 @@ func TestConwayTransactionBody_Utxorpc(t *testing.T) { // Unit test for ConwayTransaction.Utxorpc() func TestConwayTransaction_Utxorpc(t *testing.T) { - input := shelley.NewShelleyTransactionInput("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0) + input := shelley.NewShelleyTransactionInput( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + 0, + ) var inputSet conway.ConwayTransactionInputSet inputSet.SetItems([]shelley.ShelleyTransactionInput{input}) diff --git a/ledger/mary/pparams_test.go b/ledger/mary/pparams_test.go index 99df823f..26bf125f 100644 --- a/ledger/mary/pparams_test.go +++ b/ledger/mary/pparams_test.go @@ -136,7 +136,10 @@ func TestMaryUtxorpc(t *testing.T) { // Unit test for MaryTransactionInput.Utxorpc() func TestMaryTransactionInput_Utxorpc(t *testing.T) { - input := shelley.NewShelleyTransactionInput("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0) + input := shelley.NewShelleyTransactionInput( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + 0, + ) got := input.Utxorpc() want := &cardano.TxInput{ @@ -145,7 +148,11 @@ func TestMaryTransactionInput_Utxorpc(t *testing.T) { } if !reflect.DeepEqual(got, want) { - t.Errorf("MaryTransactionInput.Utxorpc() mismatch\\nGot: %+v\\nWant: %+v", got, want) + t.Errorf( + "MaryTransactionInput.Utxorpc() mismatch\\nGot: %+v\\nWant: %+v", + got, + want, + ) } } @@ -169,14 +176,23 @@ func TestMaryTransactionOutput_Utxorpc(t *testing.T) { } if !reflect.DeepEqual(got, want) { - t.Errorf("MaryTransactionOutput.Utxorpc() mismatch\\nGot: %+v\\nWant: %+v", got, want) + t.Errorf( + "MaryTransactionOutput.Utxorpc() mismatch\\nGot: %+v\\nWant: %+v", + got, + want, + ) } } // Unit test for MaryTransactionBody.Utxorpc() func TestMaryTransactionBody_Utxorpc(t *testing.T) { - input := shelley.NewShelleyTransactionInput("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", 1) - inputSet := shelley.NewShelleyTransactionInputSet([]shelley.ShelleyTransactionInput{input}) + input := shelley.NewShelleyTransactionInput( + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + 1, + ) + inputSet := shelley.NewShelleyTransactionInputSet( + []shelley.ShelleyTransactionInput{input}, + ) address := common.Address{} output := mary.MaryTransactionOutput{ @@ -211,8 +227,13 @@ func TestMaryTransactionBody_Utxorpc(t *testing.T) { // Unit test for MaryTransaction.Utxorpc() func TestMaryTransaction_Utxorpc(t *testing.T) { - input := shelley.NewShelleyTransactionInput("cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", 2) - inputSet := shelley.NewShelleyTransactionInputSet([]shelley.ShelleyTransactionInput{input}) + input := shelley.NewShelleyTransactionInput( + "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + 2, + ) + inputSet := shelley.NewShelleyTransactionInputSet( + []shelley.ShelleyTransactionInput{input}, + ) address := common.Address{} output := mary.MaryTransactionOutput{ diff --git a/ledger/shelley/pparams.go b/ledger/shelley/pparams.go index f2dceb84..7fcae5a2 100644 --- a/ledger/shelley/pparams.go +++ b/ledger/shelley/pparams.go @@ -98,7 +98,9 @@ func (p *ShelleyProtocolParameters) Update( } } -func (p *ShelleyProtocolParameters) UpdateFromGenesis(genesis *ShelleyGenesis) error { +func (p *ShelleyProtocolParameters) UpdateFromGenesis( + genesis *ShelleyGenesis, +) error { if genesis == nil { return nil } diff --git a/ledger/shelley/pparams_test.go b/ledger/shelley/pparams_test.go index e3650080..9d10659f 100644 --- a/ledger/shelley/pparams_test.go +++ b/ledger/shelley/pparams_test.go @@ -168,7 +168,10 @@ func TestShelleyUtxorpc(t *testing.T) { // Tests conversion of a ShelleyTransactionInput to its utxorpc-compatible representation. func TestShelleyTransactionInput_Utxorpc(t *testing.T) { // Create a mock transaction input with dummy transaction hash and index - input := shelley.NewShelleyTransactionInput("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 1) + input := shelley.NewShelleyTransactionInput( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + 1, + ) // Convert it to utxorpc TxInput got := input.Utxorpc() @@ -215,19 +218,32 @@ func TestShelleyTransactionOutput_Utxorpc(t *testing.T) { } // Debug prints - t.Logf("DEBUG got.Address=%#v want.Address=%#v\n", actual.Address, expected.Address) + t.Logf( + "DEBUG got.Address=%#v want.Address=%#v\n", + actual.Address, + expected.Address, + ) // Compare actual and expected results if !reflect.DeepEqual(actual, expected) { - t.Errorf("TxOutput.Utxorpc() mismatch\nGot: %+v\nWant: %+v", actual, expected) + t.Errorf( + "TxOutput.Utxorpc() mismatch\nGot: %+v\nWant: %+v", + actual, + expected, + ) } } // Test the conversion of a full ShelleyTransactionBody to utxorpc format, verifying fee, input count, and output count. func TestShelleyTransactionBody_Utxorpc(t *testing.T) { // Create input set with one mock input - input := shelley.NewShelleyTransactionInput("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", 0) - inputSet := shelley.NewShelleyTransactionInputSet([]shelley.ShelleyTransactionInput{input}) + input := shelley.NewShelleyTransactionInput( + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + 0, + ) + inputSet := shelley.NewShelleyTransactionInputSet( + []shelley.ShelleyTransactionInput{input}, + ) // Use mock address address := common.Address{} @@ -251,25 +267,42 @@ func TestShelleyTransactionBody_Utxorpc(t *testing.T) { // Check that the fee matches if actual.Fee != txBody.Fee() { - t.Errorf("TxBody.Utxorpc() fee mismatch\nGot: %d\nWant: %d", actual.Fee, txBody.Fee()) + t.Errorf( + "TxBody.Utxorpc() fee mismatch\nGot: %d\nWant: %d", + actual.Fee, + txBody.Fee(), + ) } // Check number of inputs if len(actual.Inputs) != len(txBody.Inputs()) { - t.Errorf("TxBody.Utxorpc() input length mismatch\nGot: %d\nWant: %d", len(actual.Inputs), len(txBody.Inputs())) + t.Errorf( + "TxBody.Utxorpc() input length mismatch\nGot: %d\nWant: %d", + len(actual.Inputs), + len(txBody.Inputs()), + ) } // Check number of outputs if len(actual.Outputs) != len(txBody.Outputs()) { - t.Errorf("TxBody.Utxorpc() output length mismatch\nGot: %d\nWant: %d", len(actual.Outputs), len(txBody.Outputs())) + t.Errorf( + "TxBody.Utxorpc() output length mismatch\nGot: %d\nWant: %d", + len(actual.Outputs), + len(txBody.Outputs()), + ) } } // Test the conversion of a full ShelleyTransaction to utxorpc format, verifying fee, input count, and output count. func TestShelleyTransaction_Utxorpc(t *testing.T) { // Create input set with one mock input - input := shelley.NewShelleyTransactionInput("cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", 0) - inputSet := shelley.NewShelleyTransactionInputSet([]shelley.ShelleyTransactionInput{input}) + input := shelley.NewShelleyTransactionInput( + "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + 0, + ) + inputSet := shelley.NewShelleyTransactionInputSet( + []shelley.ShelleyTransactionInput{input}, + ) // Use mock address address := common.Address{} @@ -299,16 +332,28 @@ func TestShelleyTransaction_Utxorpc(t *testing.T) { // Verify the fee if got.Fee != tx.Body.Fee() { - t.Errorf("ShelleyTransaction.Utxorpc() fee mismatch\nGot: %d\nWant: %d", got.Fee, tx.Body.Fee()) + t.Errorf( + "ShelleyTransaction.Utxorpc() fee mismatch\nGot: %d\nWant: %d", + got.Fee, + tx.Body.Fee(), + ) } // Verify input count if len(got.Inputs) != len(tx.Body.Inputs()) { - t.Errorf("ShelleyTransaction.Utxorpc() input count mismatch\nGot: %d\nWant: %d", len(got.Inputs), len(tx.Body.Inputs())) + t.Errorf( + "ShelleyTransaction.Utxorpc() input count mismatch\nGot: %d\nWant: %d", + len(got.Inputs), + len(tx.Body.Inputs()), + ) } // Verify output count if len(got.Outputs) != len(tx.Body.Outputs()) { - t.Errorf("ShelleyTransaction.Utxorpc() output count mismatch\nGot: %d\nWant: %d", len(got.Outputs), len(tx.Body.Outputs())) + t.Errorf( + "ShelleyTransaction.Utxorpc() output count mismatch\nGot: %d\nWant: %d", + len(got.Outputs), + len(tx.Body.Outputs()), + ) } }