Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hale committed Jan 19, 2022
1 parent 2868f10 commit 2df21f0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
31 changes: 31 additions & 0 deletions constructor/dsl/dsl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,37 @@ func TestParse(t *testing.T) {
file: "blah_blah.txt",
expectedErr: ErrIncorrectExtension,
},
"action: valid type": {
file: "action_valid.ros",
expectedWorkflows: []*job.Workflow{
{
Name: string(job.CreateAccount),
Concurrency: job.ReservedWorkflowConcurrency,
Scenarios: []*job.Scenario{
{
Name: "create",
Actions: []*job.Action{
{
Type: job.SetVariable,
Input: `{"network":"chrysalis-devnet", "blockchain":"iota"}`,
OutputPath: "network",
},
{
Type: job.GenerateKey,
Input: `{"curve_type": "edwards25519"}`,
OutputPath: "key",
},
{
Type: job.Derive,
Input: `{"network_identifier": {{network}},"public_key": {{key.public_key}}}`,
OutputPath: "account",
},
},
},
},
},
},
},
}

for name, test := range tests {
Expand Down
5 changes: 5 additions & 0 deletions constructor/dsl/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package dsl
import (
"bufio"
"context"
"encoding/json"
"errors"
"fmt"
"os"
Expand Down Expand Up @@ -147,6 +148,10 @@ func parseActionType(line string) (job.ActionType, string, string, error) {
divide: job.Division,
} {
tokens = strings.SplitN(remaining, symbol, split2)

if json.Valid([]byte(strings.TrimSuffix(remaining, ";"))) {
break
}
if len(tokens) == split2 {
if len(mathOperation) == 0 {
return "", "", "", ErrInvalidMathSymbol
Expand Down
10 changes: 10 additions & 0 deletions constructor/dsl/testdata/action_valid.ros
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
create_account(1){
create{
network = {"network":"chrysalis-devnet", "blockchain":"iota"};
key = generate_key({"curve_type": "edwards25519"});
account = derive({
"network_identifier": {{network}},
"public_key": {{key.public_key}}
});
}
}

0 comments on commit 2df21f0

Please sign in to comment.