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

Feature/asserter #107

Merged
merged 56 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c8ce922
started working on the asserter part of the sdk
mowkoshka Jun 4, 2022
ec18729
more asserter work
mowkoshka Jun 5, 2022
4c5f443
asserter errors
mowkoshka Jun 5, 2022
9b6637b
more work on asserter
mowkoshka Jun 6, 2022
c16735f
block asserter mostly finished
mowkoshka Jun 7, 2022
bc290b1
started fixing some clippy issues
mowkoshka Jun 7, 2022
d416f50
progress
MACS-J1149 Jun 9, 2022
d588990
get it compiling for now first currency test passes
mowkoshka Jun 10, 2022
efdf088
account tests
mowkoshka Jun 10, 2022
c1168ec
refactor add types module
mowkoshka Jun 11, 2022
13f12da
started working on asserter block tests
mowkoshka Jul 14, 2022
52a5bf3
finish up what's possible with block tests
mowkoshka Jul 16, 2022
62e2b89
error tests
mowkoshka Jul 16, 2022
22dacea
possible coin tests
mowkoshka Jul 16, 2022
8462d5c
what's possible for network and search tests
mowkoshka Jul 18, 2022
2270b4f
started working on network tests
mowkoshka Jul 18, 2022
e8e4368
more work on network tests, start server tests
mowkoshka Jul 18, 2022
1cbc320
made progress on server tests
MACS-J1149 Jul 18, 2022
f4720d3
more server tests
MACS-J1149 Jul 19, 2022
ab2e3ab
started some testing clean up, more server test works, finished netwo…
mowkoshka Jul 19, 2022
92992e6
more tests
MACS-J1149 Jul 20, 2022
b0a1443
finally finished copying server tests
MACS-J1149 Jul 20, 2022
219cff2
improved asserter testing pattern
MACS-J1149 Jul 20, 2022
ad50324
converted tests to new test pattern
MACS-J1149 Jul 20, 2022
6dbcc8e
improved stdout
MACS-J1149 Jul 20, 2022
b818ee5
Updating data to better reflect golang version and errors
mowkoshka Jul 21, 2022
e706d3f
fix enum types to match rosetta sdk
mowkoshka Jul 21, 2022
2d3b266
working on moving things over to options
MACS-J1149 Jul 22, 2022
d619582
bit more work on switching over
MACS-J1149 Jul 22, 2022
0fcb057
started fixing tests to represent new data struct changes
mowkoshka Jul 22, 2022
49d8522
finished with errors
MACS-J1149 Jul 22, 2022
fa5bbf7
clippy
MACS-J1149 Jul 22, 2022
290ff12
finally done handling nulls
MACS-J1149 Jul 22, 2022
9e3b061
all non asserter tests pass
mowkoshka Jul 24, 2022
3125153
add readmes for existing modules
mowkoshka Jul 24, 2022
268106c
added test files for types module
mowkoshka Jul 24, 2022
7990a54
fix bytes encoding and decoding
mowkoshka Jul 25, 2022
9e11594
construction tests
MACS-J1149 Jul 25, 2022
a0b1c0f
95% done serialize tests for types module
mowkoshka Jul 25, 2022
85f2ac9
fixed failing construction tests
MACS-J1149 Jul 25, 2022
c550ad1
fixed comment
MACS-J1149 Jul 25, 2022
a5de636
asserter tools 99% done
mowkoshka Jul 26, 2022
0e9415c
asserter tests done, but some are failing
mowkoshka Jul 26, 2022
0edeefa
progress on fixing asserter tests
mowkoshka Jul 27, 2022
d199e0c
all asserter tests passed
mowkoshka Jul 27, 2022
0aacde6
Create test trait for most tests, move it top level
mowkoshka Jul 27, 2022
63a9eea
started working on asserter tools tests
mowkoshka Jul 27, 2022
d93d8ca
finished asserter_test file checks
0rphon Jul 27, 2022
758d410
got asserter_tools_tests passing
0rphon Jul 27, 2022
2015b27
got most of utils_test done
0rphon Jul 28, 2022
378be1f
types utils tests done and cleaned up
mowkoshka Jul 28, 2022
888b8ea
fixed some of client, but realized more will be broken by merging in …
mowkoshka Jul 28, 2022
55d39c2
added missing test segment
0rphon Jul 28, 2022
2d8cd5c
fixed two more unused warnings
0rphon Jul 28, 2022
0fc2218
fixed failing test/incorrect test
0rphon Jul 28, 2022
0f93f06
Nullable structs macro (#108)
gluax Jul 29, 2022
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"SECP"
]
}
66 changes: 66 additions & 0 deletions Cargo.lock

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

14 changes: 7 additions & 7 deletions examples/mentat-cli/src/account.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use mentat::{identifiers::AccountIdentifier, models::Currency};
use mentat::types::{AccountIdentifier, NullableCurrency};

#[derive(Parser, Clone)]
pub(crate) struct AccountOpts {
Expand All @@ -19,12 +19,12 @@ impl AccountOpts {
.into()
}

pub(crate) fn get_currencies(&self) -> Option<Vec<Currency>> {
if self.currencies.is_empty() {
return None;
}

Some(self.currencies.iter().cloned().map(|c| c.into()).collect())
pub(crate) fn get_currencies(&self) -> Vec<Option<NullableCurrency>> {
self.currencies
.iter()
.cloned()
.map(|c| Some(c.into()))
.collect()
}
}

Expand Down
38 changes: 22 additions & 16 deletions examples/mentat-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ use clap::Parser;
use mentat::{
anyhow,
client::Client,
identifiers::{BlockIdentifier, NetworkIdentifier, PartialBlockIdentifier},
requests::{AccountBalanceRequest, AccountCoinsRequest, MetadataRequest},
serde_json::json,
tokio,
types::{
BlockIdentifier,
NetworkIdentifier,
NullableAccountBalanceRequest,
NullableAccountCoinsRequest,
NullableMetadataRequest,
PartialBlockIdentifier,
},
};

use crate::{account::AccountSubCommand, network::NetworkSubCommand};
Expand Down Expand Up @@ -33,7 +39,7 @@ struct Opts {
pub(crate) subnetwork: String,

#[clap(long)]
pub(crate) index: Option<u64>,
pub(crate) index: Option<i64>,
#[clap(long)]
pub(crate) hash: Option<String>,
}
Expand Down Expand Up @@ -102,32 +108,32 @@ async fn main() -> anyhow::Result<()> {
match &main_opts.subcmd {
MainSubCommand::Network(sub_opts) => match &sub_opts.subcmd {
NetworkSubCommand::List => {
display!(client.network_list(&MetadataRequest::default()))
display!(client.network_list(NullableMetadataRequest::default()))
}
NetworkSubCommand::Options => {
let network = get_first_network().await?;
display!(client.network_options(&network.into()));
display!(client.network_options(network.into()));
}
NetworkSubCommand::Status => {
let network = get_first_network().await?;
display!(client.network_status(&network.into()));
display!(client.network_status(network.into()));
}
},
MainSubCommand::Account(sub_opts) => match &sub_opts.subcmd {
AccountSubCommand::Balance(_opts) => {
let network = get_first_network().await?;
display!(client.account_balance(&AccountBalanceRequest {
network_identifier: network,
account_identifier: sub_opts.account_id(),
display!(client.account_balance(NullableAccountBalanceRequest {
network_identifier: Some(network),
account_identifier: Some(sub_opts.account_id()),
currencies: sub_opts.get_currencies(),
block_identifier: main_opts.partial_block_id(),
}));
}
AccountSubCommand::Coins(_opts) => {
let network = get_first_network().await?;
display!(client.account_coins(&AccountCoinsRequest {
network_identifier: network,
account_identifier: sub_opts.account_id(),
display!(client.account_coins(NullableAccountCoinsRequest {
network_identifier: Some(network),
account_identifier: Some(sub_opts.account_id()),
currencies: sub_opts.get_currencies(),
..Default::default()
}));
Expand All @@ -141,23 +147,23 @@ async fn main() -> anyhow::Result<()> {
.block_id()
.expect("Expected a block identifier (--hash, --index)");
display!(
client.block_transaction(&(network, block, transaction.clone().into()).into())
client.block_transaction((network, block, transaction.clone().into()).into())
);
} else {
// find a specific block
let block = main_opts
.partial_block_id()
.expect("Expected a partial block identifier (--hash, --index)");
display!(client.block(&(network, block).into()));
display!(client.block((network, block).into()));
}
}
MainSubCommand::Mempool(opts) => {
let network = get_first_network().await?;
// handle --transaction flag
if let Some(transaction) = &opts.transaction {
display!(client.mempool_transaction(&(network, transaction.clone().into()).into()));
display!(client.mempool_transaction((network, transaction.clone().into()).into()));
} else {
display!(client.mempool(&network.into()));
display!(client.mempool(network.into()));
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions examples/mentat-cli/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use clap::Parser;
use mentat::{
anyhow::Result,
client::Client,
identifiers::NetworkIdentifier,
requests::MetadataRequest,
types::{NetworkIdentifier, NullableMetadataRequest},
};

#[derive(Parser)]
Expand All @@ -25,11 +24,11 @@ pub(crate) async fn get_network(
client: &Client,
net_ident: NetworkIdentifier,
) -> Result<Option<NetworkIdentifier>> {
Ok(Some(
Ok(
if net_ident.blockchain.is_empty() && net_ident.network.is_empty() {
// get the first network
if let Some(net) = client
.network_list(&MetadataRequest::default())
.network_list(NullableMetadataRequest::default())
.await?
.network_identifiers
.first()
Expand All @@ -39,9 +38,9 @@ pub(crate) async fn get_network(
return Ok(None);
}
} else {
net_ident
Some(net_ident)
},
))
)
}

/// Gets the first network in the networks list, prints "null" or "network not
Expand Down
9 changes: 9 additions & 0 deletions mentat-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

extern crate proc_macro;

mod nullable;
mod route_builder;

use nullable::create_nullable_counterpart;
use proc_macro::TokenStream;
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::quote;
Expand Down Expand Up @@ -159,3 +161,10 @@ pub fn main(attr: TokenStream, item: TokenStream) -> TokenStream {
out.extend(gen_main(&server_call, server_type, cache_type));
out.into()
}

/// TODO doc
#[proc_macro_derive(Nullable, attributes(retain))]
pub fn nullable(item: TokenStream) -> TokenStream {
let item = parse_macro_input!(item as ItemStruct);
create_nullable_counterpart(item)
}
Loading