-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: encode metadata to be backwards compatible (#216)
* refactor: encode metadata to be backwards compatible * tests: fix UT * apply feedback * test: fix * fix merge issues * refactor: metadata cert versioning * test: fix ut * fix: typo * use the CertificateBuildParams * test: fix ut * Apply feedback * fix: lint
- Loading branch information
Showing
6 changed files
with
154 additions
and
50 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
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,28 @@ | ||
package types | ||
|
||
import ( | ||
"math/big" | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMetadataConversions_toBlock_Only(t *testing.T) { | ||
toBlock := uint64(123567890) | ||
hash := common.BigToHash(new(big.Int).SetUint64(toBlock)) | ||
meta := NewCertificateMetadataFromHash(hash) | ||
require.Equal(t, toBlock, meta.ToBlock) | ||
} | ||
|
||
func TestMetadataConversions(t *testing.T) { | ||
fromBlock := uint64(123567890) | ||
offset := uint32(1000) | ||
createdAt := uint32(0) | ||
meta := NewCertificateMetadata(fromBlock, offset, createdAt) | ||
c := meta.ToHash() | ||
extractBlock := NewCertificateMetadataFromHash(c) | ||
require.Equal(t, fromBlock, extractBlock.FromBlock) | ||
require.Equal(t, offset, extractBlock.Offset) | ||
require.Equal(t, createdAt, extractBlock.CreatedAt) | ||
} |