Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add go tests #4

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Conversation

GalRogozinski
Copy link

Adding tools written in go that are used to run tests and attacks on the tangle.
WIP

Copy link
Member

@luca-moser luca-moser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename the folder go-tools to tests or something more reflecting what the code under the folder is. (This because there are other applications in the root dir also written in go, so this folder name doesn't make much sense)

Comment on lines 31 to 33
Must(err)

Must(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dupped Must(err)

iota "github.com/iotaledger/iota.go/v2"
)

const blowballSize = 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be configurable through CLI.

m := SendDataMessage(nodeAPI, &nodeInfo.NetworkID, &parents, "blowball", string(i))
id, err := m.ID()
Must(err)
fmt.Println("sent blowball message ", hex.EncodeToString(id[:]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use log.Println instead

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file is a checkout error, can you please remove this from the PR?

go-tools/go.mod Outdated
@@ -0,0 +1,11 @@
module github.com/iotaledger/chrysalis-tools/go-tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to also rename the module names after changing the go-tools folder name.

)

func main() {
endpoint := flag.String("endpoint", fmt.Sprintf("http://%s:%d", nodeUrl, apiPort), "endpoint")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flag.Parse() isn't called

}

func ObtainAPI(nodeUrl string, apiPort int) (*NodeAPIClient, *NodeInfoResponse) {
endpoint := flag.String("endpoint", fmt.Sprintf("http://%s:%d", nodeUrl, apiPort), "endpoint")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag shouldn't be in this function. The caller should be set up/use the flag.

var info *iota.NodeInfoResponse

func main() {
endpoint := flag.String("endpoint", "http://localhost:14265", "endpoint")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flag.Parse() isn't called

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporarily removing this file

)

func main() {
endpoint := flag.String("endpoint", fmt.Sprintf("http://%s:%d", nodeUrl, apiPort), "endpoint")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flag.Parse() isn't called

Comment on lines 31 to 45
tx, err := iota.NewTransactionBuilder().
AddInput(CreateInput(&genesisAddress, genesisOutput, 0)).
AddOutput(CreateOutput(&address1, 825)).
AddIndexationPayload(&iota.Indexation{Index: []byte("value"), Data: []byte("test")}).
Build(signer)
Must(err)

SendValueMessage(nodeAPI, &info.NetworkID, nil, tx)

tx, err = iota.NewTransactionBuilder().
AddInput(CreateInput(&genesisAddress, genesisOutput, 0)).
AddOutput(CreateOutput(&address1, 825)).
AddIndexationPayload(&iota.Indexation{Index: []byte("value"), Data: []byte("test")}).
Build(signer)
Must(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not actually send off the 2nd transaction.

@GalRogozinski
Copy link
Author

Cleaned up the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants