Skip to content

Commit

Permalink
e2e: fees validation (#230)
Browse files Browse the repository at this point in the history
* Validate db fees
* Validate transaction transfers
* Update e2e docs & config

Signed-off-by: failfmi <[email protected]>
  • Loading branch information
failfmi authored Apr 28, 2021
1 parent 44f55d9 commit bdd6fea
Show file tree
Hide file tree
Showing 11 changed files with 424 additions and 67 deletions.
2 changes: 2 additions & 0 deletions app/domain/repository/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package repository
import "github.com/limechain/hedera-eth-bridge-validator/app/persistence/entity"

type Fee interface {
// Returns Fee. Returns nil if not found
Get(txId string) (*entity.Fee, error)
Create(entity *entity.Fee) error
UpdateStatusCompleted(txId string) error
UpdateStatusFailed(txId string) error
Expand Down
19 changes: 19 additions & 0 deletions app/persistence/fee/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package fee

import (
"errors"
"github.com/limechain/hedera-eth-bridge-validator/app/persistence/entity"
"github.com/limechain/hedera-eth-bridge-validator/app/persistence/entity/fee"
"github.com/limechain/hedera-eth-bridge-validator/config"
Expand All @@ -36,6 +37,24 @@ func NewRepository(dbClient *gorm.DB) *Repository {
}
}

// Returns Fee. Returns nil if not found
func (r Repository) Get(id string) (*entity.Fee, error) {
record := &entity.Fee{}

result := r.dbClient.
Model(entity.Fee{}).
Where("transaction_id = ?", id).
First(record)

if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, nil
}
return nil, result.Error
}
return record, nil
}

func (r Repository) Create(entity *entity.Fee) error {
return r.dbClient.Create(entity).Error
}
Expand Down
46 changes: 26 additions & 20 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,35 @@ Before you run E2E tests, you need to have a running application.

### Configuration

Configure properties, needed to run e2e tests in `e2e/config/application.yml`.
Configure properties, needed to run e2e tests in `e2e/setup/application.yml`.
**Keep in mind that most of the configuration needs to be the same as the application's**.
It supports the following configurations:

| Name | Description |
| ----------------------------------------- | ------------------------------------------------------------------------------------------ |
| `hedera.bridge_account` | The configured Bridge account. Validators listen for CryptoTranfers crediting that account |
| `hedera.topic_id` | The configured Bridge Topic. Validators watch & submit signatures to that Topic |
| `hedera.sender.account` | The account that will be sending the Hbars through the bridge |
| `hedera.sender.private_key` | The private key for the account that will be sending Hbars through the bridge |
| `hedera.ethereum.node_url` | The Ethereum Node that will be used for querying data |
| `hedera.ethereum.whbar_contract_address` | The ERC20 WHBAR contract on Ethereum |
| `hedera.ethereum.bridge_contract_address` | The Bridge contract on Ethereum |
| `hedera.validator_url` | The URL of the Validator node. Used for querying Metadata |
| `hedera.eth_signer` | The private key for the account that will execute mint transactions |
| `hedera.network_type` | Which Hedera network to use. Can be either `mainnet`, `previewnet`, `testnet`. |
| `hedera.tokens.whbar` | The whbar ID which will be used for the tests. |
| `hedera.tokens.wtoken` | The token ID which will be used for the token related tests. |
| `hedera.db_validation.host` | The IP or hostname used to connect to the database. |
| `hedera.db_validation.name` | The name of the database. |
| `hedera.db_validation.password` | The database password the processor uses to connect. |
| `hedera.db_validation.port` | The port used to connect to the database. |
| `hedera.db_validation.username` | The username the processor uses to connect to the database. |
Name | Description |
----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
`hedera.bridge_account` | The configured Bridge account. Validators listen for CRYPTOTRANSFER transactions, crediting that account.
`hedera.dbs[].host` | The IP or hostname used to connect to the database.
`hedera.dbs[].name` | The name of the database.
`hedera.dbs[].password` | The database password the processor uses to connect.
`hedera.dbs[].port` | The port used to connect to the database.
`hedera.dbs[].username` | The username the processor uses to connect to the database.
`hedera.fee_percentage` | The percentage which validators take for every bridge transfer. Range is from 0 to 100.000 (multiplied by 1 000). Examples: 1% is 1 000, 1.234% = 1234, 0.15% = 150. Default 10% = 10 000.
`hedera.members` | The Hedera account ids of the validators, to which their bridge fees will be sent (if Bridge accepts Hedera Tokens, associations with these tokens will be required). Used to assert balances after transactions.
`hedera.mirror_node.api_address` | The Hedera Rest API root endpoint. Depending on the Hedera network type, this will need to be changed.
`hedera.mirror_node.client_address` | The HCS Mirror node endpoint. Depending on the Hedera network type, this will need to be changed.
`hedera.mirror_node.max_retries` | The maximum number of retries that the mirror node has to continue monitoring after a failure, before stopping completely.
`hedera.mirror_node.polling_interval` | How often (in seconds) the application will poll the mirror node for new transactions.
`hedera.network_type` | Which Hedera network to use. Can be either `mainnet`, `previewnet`, `testnet`.
`hedera.sender.account` | The account that will be sending assets through the bridge.
`hedera.sender.private_key` | The private key for the account that will be sending assets through the bridge.
`hedera.topic_id` | The configured Bridge Topic. Validators watch & submit signatures to that Topic.
`ethereum.block_confirmations` | The number of block confirmations to wait for before processing an ethereum event.
`ethereum.node_url` | The Ethereum Node that will be used for querying data.
`ethereum.private_key` | The private key for the account which executes mint/burn operations. The derived address of the key serves as an `HBAR->Ethereum` memo (receiver).
`ethereum.router_contract_address` | The address of the Router Contract.
`tokens.whbar` | The native asset, which represents HBAR. Used as a bridged asset between the two networks.
`tokens.wtoken` | The native asset, which represents a Token on Hedera. Used as a bridged asset between the two networks.
`validator_url` | The URL of the Validator node. Used for querying Metadata.

### Run E2E Tests

Expand Down
Loading

0 comments on commit bdd6fea

Please sign in to comment.