Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions ledger/alonzo/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,19 +458,28 @@ func TestNewAlonzoGenesisFromReader(t *testing.T) {
}

if result.LovelacePerUtxoWord != 34482 {
t.Errorf("Expected LovelacePerUtxoWord 34482, got %d", result.LovelacePerUtxoWord)
t.Errorf(
"Expected LovelacePerUtxoWord 34482, got %d",
result.LovelacePerUtxoWord,
)
} else {
t.Logf("LovelacePerUtxoWord is correct: %d", result.LovelacePerUtxoWord)
}

if result.ExecutionPrices.Steps.Rat.Cmp(big.NewRat(721, 10000)) != 0 {
t.Errorf("Unexpected prSteps: got %v, expected 721/10000", result.ExecutionPrices.Steps.Rat)
t.Errorf(
"Unexpected prSteps: got %v, expected 721/10000",
result.ExecutionPrices.Steps.Rat,
)
} else {
t.Logf("prSteps is correct: %v", result.ExecutionPrices.Steps.Rat)
}

if result.ExecutionPrices.Mem.Rat.Cmp(big.NewRat(577, 10000)) != 0 {
t.Errorf("Unexpected prMem: got %v, expected 577/10000", result.ExecutionPrices.Mem.Rat)
t.Errorf(
"Unexpected prMem: got %v, expected 577/10000",
result.ExecutionPrices.Mem.Rat,
)
} else {
t.Logf("prMem is correct: %v", result.ExecutionPrices.Mem.Rat)
}
Expand All @@ -482,7 +491,11 @@ func TestNewAlonzoGenesisFromReader(t *testing.T) {
},
}
if !reflect.DeepEqual(result.CostModels, expectedCostModels) {
t.Errorf("Unexpected CostModels:\nGot: %v\nExpected: %v", result.CostModels, expectedCostModels)
t.Errorf(
"Unexpected CostModels:\nGot: %v\nExpected: %v",
result.CostModels,
expectedCostModels,
)
} else {
t.Logf("CostModels are correct")
}
Expand Down
60 changes: 52 additions & 8 deletions ledger/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func mockShelleyCBOR() []byte {
}

func mockAllegraCBOR() []byte {
allegraHeader := allegra.AllegraBlockHeader{ShelleyBlockHeader: ShelleyBlockHeader{}}
allegraHeader := allegra.AllegraBlockHeader{
ShelleyBlockHeader: ShelleyBlockHeader{},
}
data, _ := cbor.Marshal(allegraHeader)
return data
}
Expand Down Expand Up @@ -107,13 +109,55 @@ func TestNewBlockHeaderFromCbor(t *testing.T) {
expectErr bool
expectedFn string
}{
{"Shelley Block", BlockTypeShelley, mockShelleyCBOR(), false, "NewShelleyBlockHeaderFromCbor"},
{"Allegra Block", BlockTypeAllegra, mockAllegraCBOR(), false, "NewAllegraBlockHeaderFromCbor"},
{"Mary Block", BlockTypeMary, mockMaryCBOR(), false, "NewMaryBlockHeaderFromCbor"},
{"Alonzo Block", BlockTypeAlonzo, mockAlonzoCBOR(), false, "NewAlonzoBlockHeaderFromCbor"},
{"Babbage Block", BlockTypeBabbage, mockBabbageCBOR(), false, "NewBabbageBlockHeaderFromCbor"},
{"Conway Block", BlockTypeConway, mockConwayCBOR(), false, "NewConwayBlockHeaderFromCbor"},
{"Invalid Block Type", 9999, []byte{0xFF, 0x00, 0x00}, true, "UnknownFunction"},
{
"Shelley Block",
BlockTypeShelley,
mockShelleyCBOR(),
false,
"NewShelleyBlockHeaderFromCbor",
},
{
"Allegra Block",
BlockTypeAllegra,
mockAllegraCBOR(),
false,
"NewAllegraBlockHeaderFromCbor",
},
{
"Mary Block",
BlockTypeMary,
mockMaryCBOR(),
false,
"NewMaryBlockHeaderFromCbor",
},
{
"Alonzo Block",
BlockTypeAlonzo,
mockAlonzoCBOR(),
false,
"NewAlonzoBlockHeaderFromCbor",
},
{
"Babbage Block",
BlockTypeBabbage,
mockBabbageCBOR(),
false,
"NewBabbageBlockHeaderFromCbor",
},
{
"Conway Block",
BlockTypeConway,
mockConwayCBOR(),
false,
"NewConwayBlockHeaderFromCbor",
},
{
"Invalid Block Type",
9999,
[]byte{0xFF, 0x00, 0x00},
true,
"UnknownFunction",
},
}

for _, test := range tests {
Expand Down
6 changes: 5 additions & 1 deletion ledger/byron/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,11 @@ func TestNewByronGenesisFromReader(t *testing.T) {
}

if !reflect.DeepEqual(result, expected) {
t.Errorf("ByronGenesis struct does not match expected.\nGot: %#v\nExpected: %#v", result, expected)
t.Errorf(
"ByronGenesis struct does not match expected.\nGot: %#v\nExpected: %#v",
result,
expected,
)
} else {
t.Logf("ByronGenesis decoded correctly")
}
Expand Down
11 changes: 9 additions & 2 deletions ledger/conway/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,18 @@ func TestNewConwayGenesisFromReader(t *testing.T) {
reader := strings.NewReader(jsonData)
actual, err := conway.NewConwayGenesisFromReader(reader)
if err != nil {
t.Errorf("Failed to decode JSON via NewConwayGenesisFromReader: %v", err)
t.Errorf(
"Failed to decode JSON via NewConwayGenesisFromReader: %v",
err,
)
}

if !reflect.DeepEqual(expected, actual) {
t.Errorf("Mismatch between expected and actual structs\nExpected: %#v\nActual: %#v", expected, actual)
t.Errorf(
"Mismatch between expected and actual structs\nExpected: %#v\nActual: %#v",
expected,
actual,
)
} else {
t.Logf("ConwayGenesis decoded correctly and matches expected structure")
}
Expand Down
6 changes: 5 additions & 1 deletion protocol/localstatequery/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,11 @@ func TestGenesisConfigJSON(t *testing.T) {
//Compare everything after unmarshalling

if !reflect.DeepEqual(genesisConfig, result) {
t.Errorf("Mismatch after JSON marshalling/unmarshalling. Expected:\n%+v\nGot:\n%+v", genesisConfig, result)
t.Errorf(
"Mismatch after JSON marshalling/unmarshalling. Expected:\n%+v\nGot:\n%+v",
genesisConfig,
result,
)
} else {
t.Logf("Successfully validated the GenesisConfigResult after JSON marshalling and unmarshalling.")
}
Expand Down
Loading