Skip to content

Commit 3b07855

Browse files
committed
test log in contract
1 parent 31ee4d0 commit 3b07855

File tree

2 files changed

+55
-11
lines changed

2 files changed

+55
-11
lines changed

rust/examples/contract.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//! Includes testing for logging
2+
// ANCHOR: contractifce
3+
use freenet_stdlib::{info, prelude::*};
4+
5+
pub const RANDOM_SIGNATURE: &[u8] = &[6, 8, 2, 5, 6, 9, 9, 10];
6+
7+
struct Contract;
8+
9+
#[contract]
10+
impl ContractInterface for Contract {
11+
fn validate_state(
12+
_parameters: Parameters<'static>,
13+
_state: State<'static>,
14+
_related: RelatedContracts<'static>,
15+
) -> Result<ValidateResult, ContractError> {
16+
unimplemented!()
17+
}
18+
19+
fn update_state(
20+
_parameters: Parameters<'static>,
21+
_state: State<'static>,
22+
_data: Vec<UpdateData<'static>>,
23+
) -> Result<UpdateModification<'static>, ContractError> {
24+
info!("state update");
25+
todo!()
26+
}
27+
28+
fn summarize_state(
29+
_parameters: Parameters<'static>,
30+
_state: State<'static>,
31+
) -> Result<StateSummary<'static>, ContractError> {
32+
unimplemented!()
33+
}
34+
35+
fn get_state_delta(
36+
_parameters: Parameters<'static>,
37+
_state: State<'static>,
38+
_summary: StateSummary<'static>,
39+
) -> Result<StateDelta<'static>, ContractError> {
40+
unimplemented!()
41+
}
42+
}
43+
// ANCHOR_END: contractifce
44+
45+
fn main() {}
46+
47+
#[test]
48+
fn test_log() {
49+
use tracing::level_filters::LevelFilter;
50+
51+
tracing_subscriber::FmtSubscriber::builder()
52+
.with_max_level(LevelFilter::INFO)
53+
.init();
54+
info!("state update");
55+
}

rust/src/log.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,3 @@ extern "C" {
2020
#[doc(hidden)]
2121
fn __frnt__logger__info(id: i64, ptr: i64, len: i32);
2222
}
23-
24-
#[test]
25-
fn log_non_contract() {
26-
use tracing::level_filters::LevelFilter;
27-
28-
tracing_subscriber::FmtSubscriber::builder()
29-
.with_max_level(LevelFilter::INFO)
30-
.init();
31-
info!("n={}, y={:?}", 1, 2);
32-
info!("zk");
33-
}

0 commit comments

Comments
 (0)