Giter Club home page Giter Club logo

Comments (8)

miguelemosreverte avatar miguelemosreverte commented on August 19, 2024

For a moment I thought the problem was caused by me by creating the canisters manually, so I deleted them and ran

dfx canister create --all

which what it does is it looks-up the dfx.json file in order to properly load the source files and start the canisters properly.

However... no luck, guys!

$ dfx canister create --all
Creating canister "pub"...
"pub" canister created with canister id: "6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q"
Creating canister "sub"...
"sub" canister created with canister id: "a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q"
$ sh test.sh
Building canisters...
Build failed. Reason:
Build step failed for canister 6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q with error: Build failed. Reason:
Command "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/moc" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo" "-o" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/pub/pub.did" "--idl" "--actor-idl" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/idl/" "--actor-alias" "pub" "6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--actor-alias" "sub" "a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--package" "base" "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/base"
returned an error:
/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo:8.1-22.2: type error, an actor or actor class must be the only non-imported declaration in a program
(This is a limitation of the current version.)

Installing code for canister pub, with canister_id 6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q
An error occured:
Io(
Os {
code: 2,
kind: NotFound,
message: "No such file or directory",
},
)
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister 6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister 6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module

from examples.

miguelemosreverte avatar miguelemosreverte commented on August 19, 2024

Finally I arrived at the conclusion that the problem could be caused by not running

dfx build

on the pub_sub folder, so I did. But still... no luck on my end!

$ dfx build
Building canisters...
Build failed. Reason:
Build step failed for canister 6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q with error: Build failed. Reason:
Command "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/moc" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo" "-o" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/pub/pub.did" "--idl" "--actor-idl" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/idl/" "--actor-alias" "pub" "6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--actor-alias" "sub" "a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--package" "base" "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/base"
returned an error:
/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo:8.1-22.2: type error, an actor or actor class must be the only non-imported declaration in a program
(This is a limitation of the current version.)

from examples.

ggreif avatar ggreif commented on August 19, 2024

@crusso any idea how to fix this?

from examples.

kritzcreek avatar kritzcreek commented on August 19, 2024

The types here:

type Counter = { topic: Text; value: Nat; };

and here:

type Counter = { topic: Text; value: Nat; };
type Subscriber = { topic: Text; callback: shared Counter -> (); };

Need to either be moved into the actor definitions, which also means adding a public to them, or be moved into a common "Types" module that can be imported from both.

from examples.

miguelemosreverte avatar miguelemosreverte commented on August 19, 2024

Question, how to write tests? If I knew how to write them I could make a fork that uses Github CI and make a PR so that these simple bugs could be found at code review

from examples.

miguelemosreverte avatar miguelemosreverte commented on August 19, 2024

Hello, I know it does sound like a low effort comment to ask 'how to test', but in the language docs I see no mentions, and if I land over here https://github.com/dfinity/motoko-base/tree/master/test, I would still not know how to run them:

dfx test? Coming from a Scala background I would expect the two keywords to work, as in sbt test

What am I missing? Could you point me to a few links for me to study and come back with results?
Results: I firmly want to express my interest on this project and more so on making benchmarks comparisons from one example like pubsub against the exact equivalent using Scala + Akka. Adding tests to this repository is my focus right now.

from examples.

miguelemosreverte avatar miguelemosreverte commented on August 19, 2024

Is this how it works?

Building/testing

In test/, run

make

Taken from https://github.com/dfinity/motoko-base

from examples.

miguelemosreverte avatar miguelemosreverte commented on August 19, 2024

PR #52 Fixed this Issue. Closing.

from examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.