-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improved withdraw all and tests (#84)
* fix: improved withdraw all and tests * fix: integration tests * fix: added typos check, fixed typos, fixed mutation tests * fix: review fixes * chore: measured restake_all gas * feat: extensive gas_left tests
- Loading branch information
Showing
19 changed files
with
266 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,11 @@ env: | |
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
typos: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: crate-ci/[email protected] | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
|
@@ -80,7 +85,7 @@ jobs: | |
path: measured.txt | ||
|
||
push: | ||
needs: [ build, lint, unit-tests, integration-tests, measure, mutation-tests ] | ||
needs: [ build, typos, lint, unit-tests, integration-tests, measure, mutation-tests ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
|
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 |
---|---|---|
|
@@ -8,6 +8,11 @@ env: | |
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
typos: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: crate-ci/[email protected] | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -1,14 +1,50 @@ | ||
#![cfg(feature = "integration-test")] | ||
|
||
use near_sdk::{env, near_bindgen, Timestamp}; | ||
use sweat_jar_model::api::IntegrationTestMethods; | ||
use near_sdk::{env, near_bindgen, AccountId, Timestamp}; | ||
use sweat_jar_model::{api::IntegrationTestMethods, jar::JarView, ProductId}; | ||
|
||
use crate::{Contract, ContractExt}; | ||
use crate::{jar::model::Jar, Contract, ContractExt}; | ||
|
||
#[mutants::skip] | ||
#[near_bindgen] | ||
impl IntegrationTestMethods for Contract { | ||
#[mutants::skip] | ||
fn block_timestamp_ms(&self) -> Timestamp { | ||
env::block_timestamp_ms() | ||
} | ||
|
||
fn bulk_create_jars( | ||
&mut self, | ||
account_id: AccountId, | ||
product_id: ProductId, | ||
principal: u128, | ||
number_of_jars: u16, | ||
) -> Vec<JarView> { | ||
self.assert_manager(); | ||
(0..number_of_jars) | ||
.map(|_| self.create_jar_for_integration_tests(&account_id, &product_id, principal)) | ||
.collect() | ||
} | ||
} | ||
|
||
#[mutants::skip] | ||
impl Contract { | ||
fn create_jar_for_integration_tests( | ||
&mut self, | ||
account_id: &AccountId, | ||
product_id: &ProductId, | ||
amount: u128, | ||
) -> JarView { | ||
let product = self.get_product(&product_id); | ||
|
||
product.assert_enabled(); | ||
product.assert_cap(amount); | ||
|
||
let id = self.increment_and_get_last_jar_id(); | ||
let now = env::block_timestamp_ms(); | ||
let jar = Jar::create(id, account_id.clone(), product_id.clone(), amount, now); | ||
|
||
self.add_new_jar(account_id, jar.clone()); | ||
|
||
jar.into() | ||
} | ||
} |
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
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
Oops, something went wrong.