Skip to content

Commit

Permalink
wip: improving `TestInstance_ExecuteBlock_WestendRuntime_WestendBlock…
Browse files Browse the repository at this point in the history
…8077850`
  • Loading branch information
EclesioMeloJunior committed Sep 27, 2023
1 parent 7cae04d commit 0b36303
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.go -text diff=golang

lib/runtime/test_data/kusama/ filter=lfs diff=lfs merge=lfs -text
lib/runtime/test_data/polkadot/ filter=lfs diff=lfs merge=lfs -text
lib/runtime/test_data/westend/block8077850.zip filter=lfs diff=lfs merge=lfs -text
lib/runtime/test_data/polkadot/ filter=lfs diff=lfs merge=lfs -text
29 changes: 14 additions & 15 deletions lib/runtime/wazero/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,24 +415,23 @@ func TestInstance_BabeConfiguration_WestendRuntime_NoAuthorities(t *testing.T) {
func extractZippedState(t *testing.T, zippedFile, destPath string) {
r, err := zip.OpenReader(zippedFile)
require.NoError(t, err)
defer r.Close()
require.Equal(t, len(r.File), 1)

for _, f := range r.File {
outFile, err := os.OpenFile(destPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())
require.NoError(t, err)

defer outFile.Close()
f := r.File[0]
outFile, err := os.OpenFile(destPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())
require.NoError(t, err)

rc, err := f.Open()
require.NoError(t, err)
defer rc.Close()
rc, err := f.Open()
require.NoError(t, err)

_, err = io.Copy(outFile, rc)
require.NoError(t, err)
_, err = io.CopyN(outFile, rc, rc)

Check failure on line 427 in lib/runtime/wazero/instance_test.go

View workflow job for this annotation

GitHub Actions / linting

cannot use rc (variable of type io.ReadCloser) as int64 value in argument to io.CopyN

Check failure on line 427 in lib/runtime/wazero/instance_test.go

View workflow job for this annotation

GitHub Actions / unit-tests

cannot use rc (variable of type io.ReadCloser) as int64 value in argument to io.CopyN
require.NoError(t, err)

// File extracted, no need to loop further
return
}
t.Cleanup(func() {
require.NoError(t, outFile.Close())
require.NoError(t, rc.Close())
require.NoError(t, r.Close())
})
}

func TestInstance_ExecuteBlock_WestendRuntime_WestendBlock8077850(t *testing.T) {
Expand Down Expand Up @@ -481,7 +480,7 @@ func TestInstance_ExecuteBlock_WestendRuntime_WestendBlock8077850(t *testing.T)
"0x41b93a99fee24501ddeb1cc2dcfbec938c99a3d94531c7e16b4f4e102a9df38a",
}

bodyExtrinsicHashes := []string{}
var bodyExtrinsicHashes []string
for _, ext := range exts {
bodyExtrinsicHashes = append(bodyExtrinsicHashes, ext.Hash().String())
}
Expand Down

0 comments on commit 0b36303

Please sign in to comment.