Skip to content
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
6 changes: 3 additions & 3 deletions benchmarks/ping-pong/app/src/ping_pong_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use sails_rs::{client::*, collections::*, prelude::*};
pub struct PingPongProgram;
impl PingPongProgram {
pub const PING_PONG_SERVICE_ROUTE_ID: u8 = 1;
pub const ROUTE_ID_PING_PONG_SERVICE: u8 = 1;
}
impl sails_rs::client::Program for PingPongProgram {}
pub trait PingPong {
Expand All @@ -17,7 +17,7 @@ impl<E: sails_rs::client::GearEnv> PingPong for sails_rs::client::Actor<PingPong
fn ping_pong_service(
&self,
) -> sails_rs::client::Service<ping_pong_service::PingPongServiceImpl, Self::Env> {
self.service(PingPongProgram::PING_PONG_SERVICE_ROUTE_ID)
self.service(PingPongProgram::ROUTE_ID_PING_PONG_SERVICE)
}
}
pub trait PingPongCtors {
Expand All @@ -39,7 +39,7 @@ impl<E: sails_rs::client::GearEnv> PingPongCtors

pub mod io {
use super::*;
sails_rs::io_struct_impl!(NewForBench () -> (), 0, sails_rs::meta::InterfaceId::zero());
sails_rs::io_struct_impl!(NewForBench () -> (), 0);
}

pub mod ping_pong_service {
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/src/alloc_stress_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use sails_rs::{client::*, collections::*, prelude::*};
pub struct AllocStressProgram;
impl AllocStressProgram {
pub const ALLOC_STRESS_ROUTE_ID: u8 = 1;
pub const ROUTE_ID_ALLOC_STRESS: u8 = 1;
}
impl sails_rs::client::Program for AllocStressProgram {}
pub trait AllocStress {
Expand All @@ -13,7 +13,7 @@ pub trait AllocStress {
impl<E: sails_rs::client::GearEnv> AllocStress for sails_rs::client::Actor<AllocStressProgram, E> {
type Env = E;
fn alloc_stress(&self) -> sails_rs::client::Service<alloc_stress::AllocStressImpl, Self::Env> {
self.service(AllocStressProgram::ALLOC_STRESS_ROUTE_ID)
self.service(AllocStressProgram::ROUTE_ID_ALLOC_STRESS)
}
}
pub trait AllocStressCtors {
Expand All @@ -35,7 +35,7 @@ impl<E: sails_rs::client::GearEnv> AllocStressCtors

pub mod io {
use super::*;
sails_rs::io_struct_impl!(NewForBench () -> (), 0, sails_rs::meta::InterfaceId::zero());
sails_rs::io_struct_impl!(NewForBench () -> (), 0);
}

pub mod alloc_stress {
Expand Down
14 changes: 7 additions & 7 deletions benchmarks/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async fn compute_stress_bench() {
let (payload, gas) = extract_reply_and_gas(env.system(), message_id);
// Low-level approach: decoding using generated io module
let stress_resp =
crate::clients::compute_stress_client::compute_stress::io::ComputeStress::decode_reply(ComputeStressProgram::COMPUTE_STRESS_ROUTE_ID, payload.as_slice())
crate::clients::compute_stress_client::compute_stress::io::ComputeStress::decode_reply(ComputeStressProgram::ROUTE_ID_COMPUTE_STRESS, payload.as_slice())
.unwrap();
assert_eq!(stress_resp.res, expected_sum);
gas
Expand Down Expand Up @@ -108,7 +108,7 @@ async fn counter_bench() {
let (payload, gas) = extract_reply_and_gas(env.system(), message_id);
// Low-level approach: decoding using generated io module
let stress_resp = crate::clients::counter_bench_client::counter_bench::io::Inc::decode_reply(
CounterBenchProgram::COUNTER_BENCH_ROUTE_ID,
CounterBenchProgram::ROUTE_ID_COUNTER_BENCH,
payload.as_slice(),
)
.unwrap();
Expand All @@ -121,7 +121,7 @@ async fn counter_bench() {
let (payload, gas) = extract_reply_and_gas(env.system(), message_id);
// Low-level approach: decoding using generated io module
let stress_resp = crate::clients::counter_bench_client::counter_bench::io::IncAsync::decode_reply(
CounterBenchProgram::COUNTER_BENCH_ROUTE_ID,
CounterBenchProgram::ROUTE_ID_COUNTER_BENCH,
payload.as_slice(),
)
.unwrap();
Expand Down Expand Up @@ -170,7 +170,7 @@ async fn cross_program_bench() {
// Low-level approach: decoding using generated io module
let stress_resp =
ping_pong_bench_app::client::ping_pong_service::io::Ping::decode_reply(
PingPongProgram::PING_PONG_SERVICE_ROUTE_ID,
PingPongProgram::ROUTE_ID_PING_PONG_SERVICE,
payload.as_slice(),
)
.unwrap();
Expand Down Expand Up @@ -211,7 +211,7 @@ async fn redirect_bench() {
let (payload, _gas) = extract_reply_and_gas(env.system(), message_id);
// Low-level approach: decoding using generated io module
let resp = redirect_proxy_client::proxy::io::GetProgramId::decode_reply(
RedirectProxyClientProgram::PROXY_ROUTE_ID,
RedirectProxyClientProgram::ROUTE_ID_PROXY,
payload.as_slice(),
)
.unwrap();
Expand All @@ -236,7 +236,7 @@ async fn redirect_bench() {
let (payload, gas) = extract_reply_and_gas(env.system(), message_id);
// Low-level approach: decoding using generated io module
let resp = redirect_proxy_client::proxy::io::GetProgramId::decode_reply(
RedirectProxyClientProgram::PROXY_ROUTE_ID,
RedirectProxyClientProgram::ROUTE_ID_PROXY,
payload.as_slice(),
)
.unwrap();
Expand Down Expand Up @@ -284,7 +284,7 @@ async fn alloc_stress_test(n: u32) -> (usize, u64) {
// Low-level approach: decoding using generated io module
let stress_resp =
crate::clients::alloc_stress_client::alloc_stress::io::AllocStress::decode_reply(
AllocStressProgram::ALLOC_STRESS_ROUTE_ID,
AllocStressProgram::ROUTE_ID_ALLOC_STRESS,
payload.as_slice(),
)
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/src/compute_stress_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use sails_rs::{client::*, collections::*, prelude::*};
pub struct ComputeStressProgram;
impl ComputeStressProgram {
pub const COMPUTE_STRESS_ROUTE_ID: u8 = 1;
pub const ROUTE_ID_COMPUTE_STRESS: u8 = 1;
}
impl sails_rs::client::Program for ComputeStressProgram {}
pub trait ComputeStress {
Expand All @@ -19,7 +19,7 @@ impl<E: sails_rs::client::GearEnv> ComputeStress
fn compute_stress(
&self,
) -> sails_rs::client::Service<compute_stress::ComputeStressImpl, Self::Env> {
self.service(ComputeStressProgram::COMPUTE_STRESS_ROUTE_ID)
self.service(ComputeStressProgram::ROUTE_ID_COMPUTE_STRESS)
}
}
pub trait ComputeStressCtors {
Expand All @@ -41,7 +41,7 @@ impl<E: sails_rs::client::GearEnv> ComputeStressCtors

pub mod io {
use super::*;
sails_rs::io_struct_impl!(NewForBench () -> (), 0, sails_rs::meta::InterfaceId::zero());
sails_rs::io_struct_impl!(NewForBench () -> (), 0);
}

pub mod compute_stress {
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/src/counter_bench_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use sails_rs::{client::*, collections::*, prelude::*};
pub struct CounterBenchProgram;
impl CounterBenchProgram {
pub const COUNTER_BENCH_ROUTE_ID: u8 = 1;
pub const ROUTE_ID_COUNTER_BENCH: u8 = 1;
}
impl sails_rs::client::Program for CounterBenchProgram {}
pub trait CounterBench {
Expand All @@ -19,7 +19,7 @@ impl<E: sails_rs::client::GearEnv> CounterBench
fn counter_bench(
&self,
) -> sails_rs::client::Service<counter_bench::CounterBenchImpl, Self::Env> {
self.service(CounterBenchProgram::COUNTER_BENCH_ROUTE_ID)
self.service(CounterBenchProgram::ROUTE_ID_COUNTER_BENCH)
}
}
pub trait CounterBenchCtors {
Expand All @@ -41,7 +41,7 @@ impl<E: sails_rs::client::GearEnv> CounterBenchCtors

pub mod io {
use super::*;
sails_rs::io_struct_impl!(NewForBench () -> (), 0, sails_rs::meta::InterfaceId::zero());
sails_rs::io_struct_impl!(NewForBench () -> (), 0);
}

pub mod counter_bench {
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/app/tests/gclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async fn ping_pong_works() {
// Use generated `io` module for encoding/decoding calls and replies
// and send/receive bytes using `gclient` native means (env is just a wrapper)
let ping_call_payload =
ping_pong::io::Ping::encode_call(DemoClientProgram::PING_PONG_ROUTE_ID, "ping".into());
ping_pong::io::Ping::encode_call(DemoClientProgram::ROUTE_ID_PING_PONG, "ping".into());

// Act
let ping_reply_payload = env
Expand All @@ -125,7 +125,7 @@ async fn ping_pong_works() {
.unwrap();

let ping_reply = ping_pong::io::Ping::decode_reply(
DemoClientProgram::PING_PONG_ROUTE_ID,
DemoClientProgram::ROUTE_ID_PING_PONG,
ping_reply_payload,
)
.unwrap();
Expand Down
20 changes: 10 additions & 10 deletions examples/demo/app/tests/gtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ async fn ping_pong_low_level_works() {

// Use generated `io` module for encoding/decoding calls and replies
// and send/receive bytes using `gtest` native means
let ping_call_payload = Ping::encode_call(DemoClientProgram::PING_PONG_ROUTE_ID, "ping".into());
let ping_call_payload = Ping::encode_call(DemoClientProgram::ROUTE_ID_PING_PONG, "ping".into());

let message_id = demo_program.send_bytes(ACTOR_ID, ping_call_payload);
let run_result = system.run_next_block();
Expand All @@ -191,7 +191,7 @@ async fn ping_pong_low_level_works() {
let ping_reply_payload = reply_log_record.payload();

let ping_reply =
Ping::decode_reply(DemoClientProgram::PING_PONG_ROUTE_ID, ping_reply_payload).unwrap();
Ping::decode_reply(DemoClientProgram::ROUTE_ID_PING_PONG, ping_reply_payload).unwrap();

assert_eq!(ping_reply, Ok("pong".to_string()));

Expand Down Expand Up @@ -456,7 +456,7 @@ fn counter_add_low_level_works() {

// Use generated `io` module for encoding/decoding calls and replies
// and send/receive bytes using `gtest` native means
let call_payload = Add::encode_call(DemoClientProgram::COUNTER_ROUTE_ID, 10);
let call_payload = Add::encode_call(DemoClientProgram::ROUTE_ID_COUNTER, 10);

let message_id = demo_program.send_bytes(ACTOR_ID, call_payload);
let run_result = system.run_next_block();
Expand All @@ -469,7 +469,7 @@ fn counter_add_low_level_works() {

let reply_payload = reply_log_record.payload();

let reply = Add::decode_reply(DemoClientProgram::COUNTER_ROUTE_ID, reply_payload).unwrap();
let reply = Add::decode_reply(DemoClientProgram::ROUTE_ID_COUNTER, reply_payload).unwrap();

assert_eq!(reply, 10);

Expand Down Expand Up @@ -560,7 +560,7 @@ fn chaos_service_panic_after_wait_works() {

let msg_id = program.send_bytes(
ACTOR_ID,
PanicAfterWait::encode_call(DemoClientProgram::CHAOS_ROUTE_ID),
PanicAfterWait::encode_call(DemoClientProgram::ROUTE_ID_CHAOS),
);
system.run_next_block();

Expand Down Expand Up @@ -595,7 +595,7 @@ fn chaos_service_timeout_wait() {

program.send_bytes(
ACTOR_ID,
TimeoutWait::encode_call(DemoClientProgram::CHAOS_ROUTE_ID),
TimeoutWait::encode_call(DemoClientProgram::ROUTE_ID_CHAOS),
);
//#1
system.run_next_block();
Expand All @@ -614,13 +614,13 @@ fn chaos_service_timeout_wait() {

let msg_id = program.send_bytes(
ACTOR_ID,
ReplyHookCounter::encode_call(DemoClientProgram::CHAOS_ROUTE_ID),
ReplyHookCounter::encode_call(DemoClientProgram::ROUTE_ID_CHAOS),
);

let run = system.run_next_block();

let val = extract_reply(&run, msg_id, |p| {
ReplyHookCounter::decode_reply(DemoClientProgram::CHAOS_ROUTE_ID, p).unwrap()
ReplyHookCounter::decode_reply(DemoClientProgram::ROUTE_ID_CHAOS, p).unwrap()
});
assert_eq!(val, 0, "handle_reply should not trigger before reply");

Expand All @@ -633,11 +633,11 @@ fn chaos_service_timeout_wait() {

let msg_id = program.send_bytes(
ACTOR_ID,
ReplyHookCounter::encode_call(DemoClientProgram::CHAOS_ROUTE_ID),
ReplyHookCounter::encode_call(DemoClientProgram::ROUTE_ID_CHAOS),
);
let run = system.run_next_block();
let val = extract_reply(&run, msg_id, |p| {
ReplyHookCounter::decode_reply(DemoClientProgram::CHAOS_ROUTE_ID, p).unwrap()
ReplyHookCounter::decode_reply(DemoClientProgram::ROUTE_ID_CHAOS, p).unwrap()
});
assert_eq!(
val, 1,
Expand Down
61 changes: 45 additions & 16 deletions examples/demo/client/src/demo_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use core::num::NonZeroU32;
use sails_rs::{client::*, collections::*, prelude::*};
pub struct DemoClientProgram;
impl DemoClientProgram {
pub const PING_PONG_ROUTE_ID: u8 = 1;
pub const COUNTER_ROUTE_ID: u8 = 2;
pub const DOG_ROUTE_ID: u8 = 3;
pub const REFERENCES_ROUTE_ID: u8 = 4;
pub const THIS_THAT_ROUTE_ID: u8 = 5;
pub const VALUE_FEE_ROUTE_ID: u8 = 6;
pub const CHAOS_ROUTE_ID: u8 = 7;
pub const ROUTE_ID_PING_PONG: u8 = 1;
pub const ROUTE_ID_COUNTER: u8 = 2;
pub const ROUTE_ID_DOG: u8 = 3;
pub const ROUTE_ID_REFERENCES: u8 = 4;
pub const ROUTE_ID_THIS_THAT: u8 = 5;
pub const ROUTE_ID_VALUE_FEE: u8 = 6;
pub const ROUTE_ID_CHAOS: u8 = 7;
}
impl sails_rs::client::Program for DemoClientProgram {}
pub trait DemoClient {
Expand All @@ -32,25 +32,25 @@ pub trait DemoClient {
impl<E: sails_rs::client::GearEnv> DemoClient for sails_rs::client::Actor<DemoClientProgram, E> {
type Env = E;
fn ping_pong(&self) -> sails_rs::client::Service<ping_pong::PingPongImpl, Self::Env> {
self.service(DemoClientProgram::PING_PONG_ROUTE_ID)
self.service(DemoClientProgram::ROUTE_ID_PING_PONG)
}
fn counter(&self) -> sails_rs::client::Service<counter::CounterImpl, Self::Env> {
self.service(DemoClientProgram::COUNTER_ROUTE_ID)
self.service(DemoClientProgram::ROUTE_ID_COUNTER)
}
fn dog(&self) -> sails_rs::client::Service<dog::DogImpl, Self::Env> {
self.service(DemoClientProgram::DOG_ROUTE_ID)
self.service(DemoClientProgram::ROUTE_ID_DOG)
}
fn references(&self) -> sails_rs::client::Service<references::ReferencesImpl, Self::Env> {
self.service(DemoClientProgram::REFERENCES_ROUTE_ID)
self.service(DemoClientProgram::ROUTE_ID_REFERENCES)
}
fn this_that(&self) -> sails_rs::client::Service<this_that::ThisThatImpl, Self::Env> {
self.service(DemoClientProgram::THIS_THAT_ROUTE_ID)
self.service(DemoClientProgram::ROUTE_ID_THIS_THAT)
}
fn value_fee(&self) -> sails_rs::client::Service<value_fee::ValueFeeImpl, Self::Env> {
self.service(DemoClientProgram::VALUE_FEE_ROUTE_ID)
self.service(DemoClientProgram::ROUTE_ID_VALUE_FEE)
}
fn chaos(&self) -> sails_rs::client::Service<chaos::ChaosImpl, Self::Env> {
self.service(DemoClientProgram::CHAOS_ROUTE_ID)
self.service(DemoClientProgram::ROUTE_ID_CHAOS)
}
}
pub trait DemoClientCtors {
Expand Down Expand Up @@ -84,8 +84,8 @@ impl<E: sails_rs::client::GearEnv> DemoClientCtors

pub mod io {
use super::*;
sails_rs::io_struct_impl!(Default () -> (), 0, sails_rs::meta::InterfaceId::zero());
sails_rs::io_struct_impl!(New (counter: super::Option<u32, >, dog_position: super::Option<(i32, i32, ), >) -> (), 1, sails_rs::meta::InterfaceId::zero());
sails_rs::io_struct_impl!(Default () -> (), 0);
sails_rs::io_struct_impl!(New (counter: super::Option<u32, >, dog_position: super::Option<(i32, i32, ), >) -> (), 1);
}

pub mod ping_pong {
Expand Down Expand Up @@ -170,6 +170,14 @@ pub mod counter {
#[codec(index = 1)]
Subtracted(u32),
}
impl CounterEvents {
pub fn entry_id(&self) -> u16 {
match self {
Self::Added { .. } => 0,
Self::Subtracted { .. } => 1,
}
}
}
impl sails_rs::client::Event for CounterEvents {}
impl sails_rs::client::Identifiable for CounterEvents {
const INTERFACE_ID: sails_rs::InterfaceId =
Expand Down Expand Up @@ -229,6 +237,13 @@ pub mod walker_service {
#[codec(index = 0)]
Walked { from: (i32, i32), to: (i32, i32) },
}
impl WalkerServiceEvents {
pub fn entry_id(&self) -> u16 {
match self {
Self::Walked { .. } => 0,
}
}
}
impl sails_rs::client::Event for WalkerServiceEvents {}
impl sails_rs::client::Identifiable for WalkerServiceEvents {
const INTERFACE_ID: sails_rs::InterfaceId =
Expand Down Expand Up @@ -338,6 +353,13 @@ pub mod dog {
#[codec(index = 0)]
Barked,
}
impl DogEvents {
pub fn entry_id(&self) -> u16 {
match self {
Self::Barked { .. } => 0,
}
}
}
impl sails_rs::client::Event for DogEvents {}
impl sails_rs::client::Identifiable for DogEvents {
const INTERFACE_ID: sails_rs::InterfaceId =
Expand Down Expand Up @@ -582,6 +604,13 @@ pub mod value_fee {
#[codec(index = 0)]
Withheld(u128),
}
impl ValueFeeEvents {
pub fn entry_id(&self) -> u16 {
match self {
Self::Withheld { .. } => 0,
}
}
}
impl sails_rs::client::Event for ValueFeeEvents {}
impl sails_rs::client::Identifiable for ValueFeeEvents {
const INTERFACE_ID: sails_rs::InterfaceId =
Expand Down
Loading