-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored types to force runtime registrations to be type dependent (#…
…10147) This resolves #10135 All enums are constrained by their owning type which forces package includsion and hence type registration. Added tests for each type to check the construction cycle.
- Loading branch information
Showing
24 changed files
with
354 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package snaptype_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ledgerwatch/erigon/core/snaptype" | ||
) | ||
|
||
func TestEnumeration(t *testing.T) { | ||
|
||
if snaptype.Headers.Enum() != snaptype.Enums.Headers { | ||
t.Fatal("enum mismatch", snaptype.Headers, snaptype.Headers.Enum(), snaptype.Enums.Headers) | ||
} | ||
|
||
if snaptype.Bodies.Enum() != snaptype.Enums.Bodies { | ||
t.Fatal("enum mismatch", snaptype.Bodies, snaptype.Bodies.Enum(), snaptype.Enums.Bodies) | ||
} | ||
|
||
if snaptype.Transactions.Enum() != snaptype.Enums.Transactions { | ||
t.Fatal("enum mismatch", snaptype.Transactions, snaptype.Transactions.Enum(), snaptype.Enums.Transactions) | ||
} | ||
|
||
} | ||
|
||
func TestNames(t *testing.T) { | ||
|
||
if snaptype.Headers.Name() != snaptype.Enums.Headers.String() { | ||
t.Fatal("name mismatch", snaptype.Headers, snaptype.Headers.Name(), snaptype.Enums.Headers.String()) | ||
} | ||
|
||
if snaptype.Bodies.Name() != snaptype.Enums.Bodies.String() { | ||
t.Fatal("name mismatch", snaptype.Bodies, snaptype.Bodies.Name(), snaptype.Enums.Bodies.String()) | ||
} | ||
|
||
if snaptype.Transactions.Name() != snaptype.Enums.Transactions.String() { | ||
t.Fatal("name mismatch", snaptype.Transactions, snaptype.Transactions.Name(), snaptype.Enums.Transactions.String()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package snaptype_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ledgerwatch/erigon-lib/downloader/snaptype" | ||
) | ||
|
||
func TestEnumeration(t *testing.T) { | ||
|
||
if snaptype.BlobSidecars.Enum() != snaptype.CaplinEnums.BlobSidecars { | ||
t.Fatal("enum mismatch", snaptype.BlobSidecars, snaptype.BlobSidecars.Enum(), snaptype.CaplinEnums.BlobSidecars) | ||
} | ||
|
||
if snaptype.BeaconBlocks.Enum() != snaptype.CaplinEnums.BeaconBlocks { | ||
t.Fatal("enum mismatch", snaptype.BeaconBlocks, snaptype.BeaconBlocks.Enum(), snaptype.CaplinEnums.BeaconBlocks) | ||
} | ||
} | ||
|
||
func TestNames(t *testing.T) { | ||
|
||
if snaptype.BeaconBlocks.Name() != snaptype.CaplinEnums.BeaconBlocks.String() { | ||
t.Fatal("name mismatch", snaptype.BeaconBlocks, snaptype.BeaconBlocks.Name(), snaptype.CaplinEnums.BeaconBlocks.String()) | ||
} | ||
|
||
if snaptype.BlobSidecars.Name() != snaptype.CaplinEnums.BlobSidecars.String() { | ||
t.Fatal("name mismatch", snaptype.BlobSidecars, snaptype.BlobSidecars.Name(), snaptype.CaplinEnums.BlobSidecars.String()) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.