Skip to content

Commit

Permalink
Fixing bugs in rust crates where the name of the crates would not be …
Browse files Browse the repository at this point in the history
…valid
  • Loading branch information
ShivanshVij committed Aug 28, 2023
1 parent 5bff700 commit 9a38b83
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func LocalGolang(options *LocalGolangOptions) (*scalefunc.Schema, error) {
case WASITarget:
target = "wasi"
default:
return nil, fmt.Errorf("unknown build target %s", options.Target)
return nil, fmt.Errorf("unknown build target %d", options.Target)
}

buildArgs := append([]string{"build", "-o", "scale.wasm"}, options.Args...)
Expand Down Expand Up @@ -387,7 +387,7 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) {
case WASITarget:
target = "wasm32-wasi"
default:
return nil, fmt.Errorf("unknown build target %s", options.Target)
return nil, fmt.Errorf("unknown build target %d", options.Target)
}

buildArgs := append([]string{"build"}, options.Args...)
Expand Down
2 changes: 1 addition & 1 deletion integration/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestGenerateMasterTestingSchema(t *testing.T) {
GolangPolyglotVersion: version.Version(),

RustPackageName: "local_example_latest_guest",
RustPackageVersion: "0.1.0",
RustPackageVersion: "v0.1.0",
RustPolyglotVersion: strings.TrimPrefix(version.Version(), "v"),
})
require.NoError(t, err)
Expand Down
13 changes: 10 additions & 3 deletions integration/golang_tests/signature/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ module signature
go 1.20

require (
github.com/loopholelabs/polyglot v1.1.2

)
github.com/loopholelabs/polyglot v1.1.2
github.com/stretchr/testify v1.8.4

)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 1 addition & 1 deletion integration/rust_tests/generated/generated.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by scale-signature v0.1.0, DO NOT EDIT.
// Code generated by scale-signature 0.1.0, DO NOT EDIT.
// output: generated

#![allow(dead_code)]
Expand Down
4 changes: 2 additions & 2 deletions integration/rust_tests/signature/tests/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ mod tests {
use std::fs;
use std::error::Error;
use std::io::{Cursor, Seek, SeekFrom};
use signature::types;
use signature::types::{Encode, Decode};
use local_example_latest_guest::types;
use local_example_latest_guest::types::{Encode, Decode};

#[test]
fn test_output() -> Result<(), Box<dyn Error>> {
Expand Down
4 changes: 2 additions & 2 deletions signature/generator/rust/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (g *Generator) Generate(schema *signature.Schema, packageName string, scale
buf := new(bytes.Buffer)
err := g.templ.ExecuteTemplate(buf, "types.rs.templ", map[string]any{
"schema": schema,
"version": scaleVersion,
"version": strings.TrimPrefix(scaleVersion, "v"),
"package": packageName,
})
if err != nil {
Expand All @@ -102,7 +102,7 @@ func (g *Generator) GenerateCargofile(packageName string, packageVersion string,
"scale_version": strings.TrimPrefix(scaleVersion, "v"),
"polyglot_version": strings.TrimPrefix(polyglotVersion, "v"),
"package": packageName,
"version": packageVersion,
"version": strings.TrimPrefix(packageVersion, "v"),
})
if err != nil {
return nil, err
Expand Down

0 comments on commit 9a38b83

Please sign in to comment.