Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Test: (In)valid bundle regressions #1784

Open
wants to merge 29 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python-regression/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
author='DyrellC',
packages=['util','tests'],
install_requires=[
'pyota',
'pyota[pow]',
'aloe',
'pyyaml',
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Feature: Test Bootstrapping With LS
|keys |values |type |
|state |True |bool |


@getNodeInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

huh?

Scenario: Old transactions are pruned
Takes a node with a large db and transaction pruning enabled, and checks to make sure that the transactions below
the pruning depth are no longer present.
Expand Down
112 changes: 111 additions & 1 deletion python-regression/tests/features/machine3/3_transaction_tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ Feature: Test transaction confirmation
| keys | values | type |
| states | False | boolListMixed |


Scenario: Value Transactions are confirmed
In this test, a number of value transactions will be made to a specified node.
A milestone will be issued that references these transactions, and this should
Expand Down Expand Up @@ -87,3 +86,114 @@ Feature: Test transaction confirmation
| keys | values | type |
| states | False | boolListMixed |

Scenario: Valid value transfer bundle that doesnt affect ledger state
We want to ascertain that ledger state is always calculated correctly.
Even in the presence of a bundle that handles funds but without changing address

Then "1" transaction is issued on "nodeA-m3" with:
|keys |values |type |
|address |TEST_ADDRESS |staticValue |
|value |0 |int |
|tag |ZERO9VALUE |string |

Then a value bundle which moves funds back and forth from an address is generated referencing the previous transaction with:
|keys |values |type |
|seed |THE_BANK |staticList |
|value |100 |int |
|tag |FAKE9VALUE |string |

Then a transaction is issued referencing the previous transaction
|keys |values |type |
|seed |THE_BANK |staticList |
|address |TEST_ADDRESS |staticValue |
|value |11 |int |
|tag |VALUE9TRANSACTION |string |
Copy link
Contributor

Choose a reason for hiding this comment

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

The flow of this scenario could be easier to understand if you use When, Given, And and Then more appropriately.

Copy link
Contributor

Choose a reason for hiding this comment

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


#In the default test, the latest sent index will be 52. The next milestone issued should be 53.
When a milestone is issued with index 53 and references:
|keys |values |type |
|transactions |previousTransaction |responseValue |

#Give the node time to solidify the milestone
And we wait "15" second/seconds

Given "getBalances" is called on "nodeA-m3" with:
|keys |values |type |
|addresses |FAKE_SPEND_ADDRESSES |staticList |

Then the response for "getBalances" should return with:
|keys |values |type |
|balances |0 |int |

Scenario: Double spend only affects the ledger once
We want to ascertain that ledger state is always calculated correctly.
Even in the presence of double spend, the confirmed state should have spent only once

Then "1" transaction is issued on "nodeA-m3" with:
|keys |values |type |
|address |TEST_ADDRESS |staticValue |
|value |0 |int |
|tag |ZERO9VALUE |string |

Then a double spend is generated referencing the previous transaction with:
|keys |values |type |
|seed |DOUBLE_SPEND_SEED |staticValue |
|value |1000 |int |
|tag |FAKE9VALUE |string |

#In the default test, the latest sent index will be 53. The next milestone issued should be 54.
When a milestone is issued with index 54 and references:
|keys |values |type |
|transactions |firstDoubleSpend |responseValue |

#Give the node time to solidify the milestone
And we wait "15" second/seconds

Given "getBalances" is called on "nodeA-m3" with:
|keys |values |type |
|addresses |DOUBLE_SPEND_ADDRESSES |staticList |

Then the response for "getBalances" should return with:
|keys |values |type |
|balances |1000 0 |intList |

Scenario: Split transaction over 2 bundles
We want to ascertain that ledger state is always calculated correctly.
Even when there is a transaction used in 2 different bundles. A split bundle is
a bundle that uses a transaction from another bundle.

Then "1" transaction is issued on "nodeA-m3" with:
|keys |values |type |
|address |TEST_ADDRESS |staticValue |
|value |0 |int |
|tag |ZERO9VALUE |string |

Then a split bundle is generated referencing the previous transaction with:
|keys |values |type |
|seed |SPLIT_BUNDLE_SEED |staticValue |
|value |2000 |int |
|tag |FAKE9VALUE |string |
|address |SPLIT_TO_ADDRESS |staticValue |

Then a transaction is issued referencing the previous transaction
|keys |values |type |
|seed |THE_BANK |staticList |
|address |TEST_ADDRESS |staticValue |
|value |11 |int |
|tag |VALUE9TRANSACTION |string |

#In the default test, the latest sent index will be 54. The next milestone issued should be 55.
When a milestone is issued with index 55 and references:
|keys |values |type |
|transactions |previousTransaction |responseValue |

#Give the node time to solidify the milestone
And we wait "15" second/seconds

Given "getBalances" is called on "nodeA-m3" with:
|keys |values |type |
|addresses |SPLIT_TO_ADDRESS |staticList |

Then the response for "getBalances" should return with:
|keys |values |type |
|balances |2000 |intList |
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Feature: Test transaction confirmation

Scenario: Invalid bundle doesnt affect ledger state
We want to ascertain that ledger state is always calculated correctly.
Even in the presence of invalid bundles being approved.

Given "1" transaction is issued on "nodeA-m3" with:
|keys |values |type |
|address |TEST_ADDRESS |staticValue |
|value |0 |int |
|tag |ZERO9VALUE |string |

Then an invalid bundle is generated referencing the previous transaction

Then a transaction is issued referencing the previous transaction
|keys |values |type |
|seed |THE_BANK |staticList |
|address |TEST_ADDRESS |staticValue |
|value |10 |int |
|tag |VALUE9TRANSACTION |string |

#In the default test, the latest sent index will be 52. The next milestone issued should be 53.
When a milestone is issued with index 51 and references:
|keys |values |type |
|transactions |previousTransaction |responseValue |

#Give the node time to solidify the milestone
And we wait "15" second/seconds

Given "getBalances" is called on "nodeA-m3" with:
|keys |values |type |
|addresses |TEST_EMPTY_ADDRESS |staticList |

Then the response for "getBalances" should return with:
|keys |values |type |
|balances |0 |int |


Scenario: Incomplete bundle doesnt affect ledger state
We want to ascertain that ledger state is always calculated correctly.
Even in the presence of incomplete bundles being approved.

Then "1" transaction is issued on "nodeA-m3" with:
|keys |values |type |
|address |TEST_ADDRESS |staticValue |
|value |0 |int |
|tag |ZERO9VALUE |string |

Then an incomplete bundle is generated referencing the previous transaction with:
|keys |values |type |
|address |TEST_EMPTY_ADDRESS |staticValue |
|tag |INCOMPLETE9TAG |string |

Then a transaction is issued referencing the previous transaction
|keys |values |type |
|seed |THE_BANK |staticList |
|address |TEST_ADDRESS |staticValue |
|value |11 |int |
|tag |VALUE9TRANSACTION |string |

#In the default test, the latest sent index will be 53. The next milestone issued should be 54.
When a milestone is issued with index 54 and references:
|keys |values |type |
|transactions |previousTransaction |responseValue |

#Give the node time to solidify the milestone
And we wait "10" second/seconds

Given "getBalances" is called on "nodeA-m3" with:
|keys |values |type |
|addresses |TEST_EMPTY_ADDRESS |staticList |

Then the response for "getBalances" should return with:
|keys |values |type |
|balances |0 |int |
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also move this to a different PR?
Less chances we will forget about this and it will also help @acha-bill ...

4 changes: 2 additions & 2 deletions python-regression/tests/features/machine3/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defaults: &transaction_tests_config_files
db: https://s3.eu-central-1.amazonaws.com/iotaledger-dbfiles/dev/Transactions_Tests_db.tar
db_checksum: 756237276479da4b01deaa0c1211ca65a4c8ec6f081452ea7e8153648c53bd67
db: https://s3.eu-central-1.amazonaws.com/iotaledger-dbfiles/dev/TransactionsTestsDb.tar
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the change to this DB documented?
Talk to @DyrellC about how to document this

db_checksum: 4d94ae65b38ea0f8461d5ec24e5140b20eb86590d54e87e30aa9a72b26a131be
iri_args: ['--testnet-coordinator',
'EFPNKGPCBXXXLIBYFGIGYBYTFFPIOQVNNVVWTTIYZO9NFREQGVGDQQHUUQ9CLWAEMXVDFSSMOTGAHVIBH',
'--milestone-start',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ Feature: Test API calls on Machine 1
Given "getBalances" is called on "nodeA-m4" with:
|keys |values |type |
|addresses |TEST_EMPTY_ADDRESS |staticList |
|threshold |100 |int |
Copy link
Contributor

Choose a reason for hiding this comment

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

this should have been part of #1768
usually I would say to move this to another PR but I am getting soft


Then the response for "getBalances" should return with:
|keys |values |type |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,12 @@ def check_response_for_value(step, api_call):
expected_values = {}
args = step.hashes
api_utils.prepare_options(args, expected_values)

for expected_value_key in expected_values:
if expected_value_key in response_values:
expected_value = expected_values[expected_value_key]
response_value = response_values[expected_value_key]

if isinstance(response_value, list) and api_call != 'getTrytes' and api_call != 'getInclusionStates':
if isinstance(response_value, list) and isinstance(expected_value, list) != True and api_call != 'getTrytes' and api_call != 'getInclusionStates':
response_value = response_value[0]

assert expected_value == response_value, "The expected value {} does not match""\
Expand Down
Loading