Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/stateful tests #10

Merged
merged 8 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Run tests
run: cargo test --features package-loader/build-time-blueprints
run: cargo test --workspace --features package-loader/build-time-blueprints --exclude stateful-tests
env:
# Enable sccache
SCCACHE_GHA_ENABLED: "true"
Expand Down
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ members = [
# Tools
"tools/publishing-tool",
# Tests
"tests"
"testing/tests",
"testing/stateful-tests"
]

[workspace.package]
Expand All @@ -43,6 +44,8 @@ radix-engine-store-interface = { git = "https://github.com/radixdlt/radixdlt-scr
scrypto-unit = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "4887c5e4be2603433592ed290b70b1a0c03cced3" }
scrypto-test = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "4887c5e4be2603433592ed290b70b1a0c03cced3" }

state-manager = { git = "https://github.com/radixdlt/babylon-node", rev = "63a8267196995fef0830e4fbf0271bea65c90ab1" }

[profile.release]
opt-level = 'z'
lto = true
Expand All @@ -68,4 +71,4 @@ radix-engine-queries = { git = "https://www.github.com/radixdlt/radixdlt-scrypto
radix-engine-interface = { git = "https://www.github.com/radixdlt/radixdlt-scrypto.git", rev = "4887c5e4be2603433592ed290b70b1a0c03cced3" }
radix-engine-store-interface = { git = "https://www.github.com/radixdlt/radixdlt-scrypto.git", rev = "4887c5e4be2603433592ed290b70b1a0c03cced3" }
scrypto-unit = { git = "https://www.github.com/radixdlt/radixdlt-scrypto.git", rev = "4887c5e4be2603433592ed290b70b1a0c03cced3" }
scrypto-test = { git = "https://www.github.com/radixdlt/radixdlt-scrypto.git", rev = "4887c5e4be2603433592ed290b70b1a0c03cced3" }
scrypto-test = { git = "https://www.github.com/radixdlt/radixdlt-scrypto.git", rev = "4887c5e4be2603433592ed290b70b1a0c03cced3" }
17 changes: 10 additions & 7 deletions packages/ignition/src/blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ mod ignition {
protocol_owner,
protocol_manager
];
set_maximum_allowed_price_staleness => restrict_to: [
set_maximum_allowed_price_staleness_in_seconds => restrict_to: [
protocol_owner,
protocol_manager
];
Expand Down Expand Up @@ -289,7 +289,7 @@ mod ignition {

/// The maximum allowed staleness of prices in seconds. If a price is
/// found to be older than this then it is deemed to be invalid.
maximum_allowed_price_staleness: i64,
maximum_allowed_price_staleness_in_seconds: i64,

/// The maximum percentage of price difference the protocol is willing
/// to accept before deeming the price difference to be too much. This
Expand All @@ -310,7 +310,7 @@ mod ignition {
/* Initial Configuration */
protocol_resource: ResourceManager,
oracle_adapter: ComponentAddress,
maximum_allowed_price_staleness: i64,
maximum_allowed_price_staleness_in_seconds: i64,
maximum_allowed_price_difference_percentage: Decimal,
/* Initializers */
initialization_parameters: InitializationParameters,
Expand Down Expand Up @@ -344,7 +344,7 @@ mod ignition {
reward_rates: KeyValueStore::new_with_registered_type(),
is_open_position_enabled: false,
is_close_position_enabled: false,
maximum_allowed_price_staleness,
maximum_allowed_price_staleness_in_seconds,
maximum_allowed_price_difference_percentage,
user_resource_volatility:
KeyValueStore::new_with_registered_type(),
Expand Down Expand Up @@ -1546,9 +1546,12 @@ mod ignition {
///
/// * `value`: [`i64`] - The maximum allowed staleness period in
/// seconds.
pub fn set_maximum_allowed_price_staleness(&mut self, value: i64) {
pub fn set_maximum_allowed_price_staleness_in_seconds(
&mut self,
value: i64,
) {
assert!(value >= 0, "{}", INVALID_MAXIMUM_PRICE_STALENESS);
self.maximum_allowed_price_staleness = value
self.maximum_allowed_price_staleness_in_seconds = value
}

/// Adds a rewards rate to the protocol.
Expand Down Expand Up @@ -1801,7 +1804,7 @@ mod ignition {
let (price, last_update) =
self.oracle_adapter.get_price(base, quote);
let final_price_validity = last_update
.add_seconds(self.maximum_allowed_price_staleness)
.add_seconds(self.maximum_allowed_price_staleness_in_seconds)
.unwrap_or(Instant::new(i64::MAX));

// Check for staleness
Expand Down
50 changes: 50 additions & 0 deletions testing/stateful-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[package]
name = "stateful-tests"
version.workspace = true
edition.workspace = true
description = "A crate that tests Ignition against the current mainnet state"

[dependencies]
sbor = { workspace = true }
transaction = { workspace = true }
scrypto-test = { workspace = true }
scrypto-unit = { workspace = true }
radix-engine = { workspace = true }
radix-engine-common = { workspace = true }
radix-engine-interface = { workspace = true }

state-manager = { workspace = true }

common = { path = "../../libraries/common" }
ignition = { path = "../../packages/ignition", features = ["test"] }
simple-oracle = { path = "../../packages/simple-oracle", features = ["test"] }
ports-interface = { path = "../../libraries/ports-interface" }
ociswap-v1-adapter-v1 = { path = "../../packages/ociswap-v1-adapter-v1", features = [
"test",
"manifest-builder-stubs"
] }
ociswap-v2-adapter-v1 = { path = "../../packages/ociswap-v2-adapter-v1", features = [
"test",
"manifest-builder-stubs"
] }
defiplaza-v2-adapter-v1 = { path = "../../packages/defiplaza-v2-adapter-v1", features = [
"test",
"manifest-builder-stubs"
] }
caviarnine-v1-adapter-v1 = { path = "../../packages/caviarnine-v1-adapter-v1", features = [
"test",
"manifest-builder-stubs"
] }

package-loader = { path = "../../libraries/package-loader" }
gateway-client = { path = "../../libraries/gateway-client" }
publishing-tool = { path = "../../tools/publishing-tool" }

paste = { version = "1.0.14" }
extend = { version = "1.2.0" }

macro_rules_attribute = { version = "0.2.0" }
lazy_static = "1.4.0"

[lints]
workspace = true
Loading
Loading