This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix) Check for duplicate clauses for same request, add dispatch tests
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
- Loading branch information
1 parent
c54edcc
commit 76d737d
Showing
11 changed files
with
9,252 additions
and
8,961 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Feature: Dispatch Tests | ||
This describe the expected behavior when dispatching requests to a clause | ||
|
||
Background: | ||
Given the Ergo contract "org.accordproject.dispatchtest.DispatchTest" in file "data/dispatchtest/logic.ergo" | ||
And the model in file "data/dispatchtest/model.cto" | ||
And the contract data | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.TemplateModel" | ||
} | ||
""" | ||
|
||
Scenario: The contract should fail executing when an import is missing | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request1" | ||
} | ||
""" | ||
Then it should fail with the error | ||
""" | ||
{ | ||
"kind": "CompilationError", | ||
"message": "Duplicate clauses for the same request type", | ||
"locstart": { | ||
"line": 16, | ||
"character": 0 | ||
}, | ||
"locend": { | ||
"line": 37, | ||
"character": 1 | ||
} | ||
} | ||
""" | ||
|
111 changes: 111 additions & 0 deletions
111
packages/ergo-engine/test/features/dispatchtest2.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
Feature: Dispatch Tests | ||
This describe the expected behavior when dispatching requests to a clause | ||
|
||
Background: | ||
Given the Ergo contract "org.accordproject.dispatchtest.DispatchTest" in file "data/dispatchtest/logic2.ergo" | ||
And the model in file "data/dispatchtest/model.cto" | ||
And the contract data | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.TemplateModel" | ||
} | ||
""" | ||
|
||
Scenario: The contract should initialize | ||
Then the initial state should be the default state | ||
|
||
Scenario: The contract should return the correct response for a Request1 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request1" | ||
} | ||
""" | ||
Then it should respond with | ||
""" | ||
{ | ||
"message": "I am a request1", | ||
"$class": "org.accordproject.dispatchtest.Response" | ||
} | ||
""" | ||
|
||
Scenario: The contract should return the correct response for a Request2 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request2" | ||
} | ||
""" | ||
Then it should respond with | ||
""" | ||
{ | ||
"message": "I am a request1", | ||
"$class": "org.accordproject.dispatchtest.Response" | ||
} | ||
""" | ||
|
||
Scenario: The contract should return the correct response for a Request3 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request3" | ||
} | ||
""" | ||
Then it should respond with | ||
""" | ||
{ | ||
"message": "I am a request3", | ||
"$class": "org.accordproject.dispatchtest.Response" | ||
} | ||
""" | ||
|
||
Scenario: The contract should return the correct response for a Request4 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request4" | ||
} | ||
""" | ||
Then it should respond with | ||
""" | ||
{ | ||
"message": "I am a request4", | ||
"$class": "org.accordproject.dispatchtest.Response" | ||
} | ||
""" | ||
|
||
Scenario: The contract should return the correct response for a Request5 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request5" | ||
} | ||
""" | ||
Then it should fail with the error | ||
""" | ||
{ | ||
"kind": "ErgoError", | ||
"message": { | ||
"type": ["org.accordproject.ergo.stdlib.ErgoErrorResponse"], | ||
"data": { | ||
"message": "Dispatch Error: no clause in the contract matches the request" | ||
} | ||
} | ||
} | ||
""" | ||
|
||
Scenario: The contract should return the correct response for a Request6 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request6" | ||
} | ||
""" | ||
Then it should respond with | ||
""" | ||
{ | ||
"message": "I am a request6", | ||
"$class": "org.accordproject.dispatchtest.Response" | ||
} | ||
""" | ||
|
111 changes: 111 additions & 0 deletions
111
packages/ergo-engine/test/features/dispatchtest3.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
Feature: Dispatch Tests | ||
This describe the expected behavior when dispatching requests to a clause | ||
|
||
Background: | ||
Given the Ergo contract "org.accordproject.dispatchtest.DispatchTest" in file "data/dispatchtest/logic3.ergo" | ||
And the model in file "data/dispatchtest/model.cto" | ||
And the contract data | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.TemplateModel" | ||
} | ||
""" | ||
|
||
Scenario: The contract should initialize | ||
Then the initial state should be the default state | ||
|
||
Scenario: The contract should return the correct response for a Request1 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request1" | ||
} | ||
""" | ||
Then it should respond with | ||
""" | ||
{ | ||
"message": "I am a request1", | ||
"$class": "org.accordproject.dispatchtest.Response" | ||
} | ||
""" | ||
|
||
Scenario: The contract should return the correct response for a Request2 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request2" | ||
} | ||
""" | ||
Then it should respond with | ||
""" | ||
{ | ||
"message": "I am a request1", | ||
"$class": "org.accordproject.dispatchtest.Response" | ||
} | ||
""" | ||
|
||
Scenario: The contract should return the correct response for a Request3 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request3" | ||
} | ||
""" | ||
Then it should respond with | ||
""" | ||
{ | ||
"message": "I am a request3", | ||
"$class": "org.accordproject.dispatchtest.Response" | ||
} | ||
""" | ||
|
||
Scenario: The contract should return the correct response for a Request4 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request4" | ||
} | ||
""" | ||
Then it should respond with | ||
""" | ||
{ | ||
"message": "I am a request4", | ||
"$class": "org.accordproject.dispatchtest.Response" | ||
} | ||
""" | ||
|
||
Scenario: The contract should return the correct response for a Request5 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request5" | ||
} | ||
""" | ||
Then it should fail with the error | ||
""" | ||
{ | ||
"kind": "ErgoError", | ||
"message": { | ||
"type": ["org.accordproject.ergo.stdlib.ErgoErrorResponse"], | ||
"data": { | ||
"message": "Dispatch Error: no clause in the contract matches the request" | ||
} | ||
} | ||
} | ||
""" | ||
|
||
Scenario: The contract should return the correct response for a Request6 | ||
When it receives the request | ||
""" | ||
{ | ||
"$class": "org.accordproject.dispatchtest.Request6" | ||
} | ||
""" | ||
Then it should respond with | ||
""" | ||
{ | ||
"message": "I am a request6", | ||
"$class": "org.accordproject.dispatchtest.Response" | ||
} | ||
""" | ||
|