-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement parachain inherents (#2566)
- Added support for parachain inherent and newheads - Improved inherentsData's encode function - Made inherent identifers enums - Common setInherent function
- Loading branch information
1 parent
3ddde15
commit e522a25
Showing
16 changed files
with
848 additions
and
93 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,45 @@ | ||
// Copyright 2022 ChainSafe Systems (ON) | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
package types | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestInherentDataMarshal(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
getInherentData func(t *testing.T) *InherentData | ||
want []byte | ||
}{ | ||
{ | ||
/* | ||
let mut data = InherentData::new(); | ||
let timestamp: u64 = 99; | ||
data.put_data(*b"babeslot", ×tamp).unwrap(); | ||
data.put_data(*b"timstap0", ×tamp).unwrap(); | ||
*/ | ||
getInherentData: func(t *testing.T) *InherentData { | ||
id := NewInherentData() | ||
err := id.SetInherent(Babeslot, uint64(99)) | ||
require.NoError(t, err) | ||
|
||
err = id.SetInherent(Timstap0, uint64(99)) | ||
require.NoError(t, err) | ||
return id | ||
}, | ||
want: []byte{8, 98, 97, 98, 101, 115, 108, 111, 116, 32, 99, 0, 0, 0, 0, 0, 0, 0, 116, 105, 109, 115, 116, 97, 112, 48, 32, 99, 0, 0, 0, 0, 0, 0, 0}, //nolint:lll | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
idata := tt.getInherentData(t) | ||
got, err := idata.Encode() | ||
require.NoError(t, err) | ||
require.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} |
Oops, something went wrong.