Skip to content
Open
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
1 change: 0 additions & 1 deletion .github/workflows/tests-p2p.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
- net::tests::convergence::test_walk_star_15_pingback
- net::tests::convergence::test_walk_star_15_org_biased
- net::tests::convergence::test_walk_inbound_line_15
- net::api::tests::postblock_proposal::test_try_make_response
- net::server::test::test_http_10_threads_getinfo
- net::server::test::test_http_10_threads_getblock
- net::server::test::test_http_too_many_clients
Expand Down
223 changes: 34 additions & 189 deletions stackslib/src/net/api/tests/getmapentry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::net::{IpAddr, Ipv4Addr, SocketAddr};

use clarity::types::chainstate::StacksBlockId;
use clarity::vm::types::QualifiedContractIdentifier;
use clarity::vm::types::{QualifiedContractIdentifier, StacksAddressExtensions, TupleData};
use clarity::vm::{ClarityName, Value};
use stacks_common::types::chainstate::StacksAddress;
use stacks_common::types::Address;
Expand Down Expand Up @@ -146,6 +146,27 @@ fn test_try_make_response() {
);
requests.push(request);

// query existing with a tuple-typed key and without a MARF proof
let account = StacksAddress::from_string("ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R")
.unwrap()
.to_account_principal();
let request = StacksHttpRequest::new_getmapentry(
addr.into(),
StacksAddress::from_string("ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R").unwrap(),
"hello-world".try_into().unwrap(),
"unit-map".try_into().unwrap(),
Value::Tuple(
TupleData::from_data(vec![(
ClarityName::from_literal("account"),
Value::Principal(account),
)])
.unwrap(),
),
TipRequest::UseLatestAnchoredTip,
false,
);
requests.push(request);

let mut responses = test_rpc(function_name!(), requests);

// latest data
Expand Down Expand Up @@ -191,196 +212,20 @@ fn test_try_make_response() {
let resp = response.decode_map_entry_response().unwrap();
assert_eq!(resp.data, "0x09");
assert_eq!(resp.marf_proof, Some("".to_string()));
}

/*
#[test]
#[ignore]
fn test_rpc_get_map_entry() {
// Test v2/map_entry (aka GetMapEntry) endpoint.
// In this test, we don't set any tip parameters, and we expect that querying for map data
// against the canonical Stacks tip will succeed.
test_rpc(
function_name!(),
40130,
40131,
50130,
50131,
true,
|ref mut peer_client,
ref mut convo_client,
ref mut peer_server,
ref mut convo_server| {
let principal =
StacksAddress::from_string("ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R")
.unwrap()
.to_account_principal();
convo_client.new_getmapentry(
StacksAddress::from_string("ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R")
.unwrap(),
"hello-world".try_into().unwrap(),
"unit-map".try_into().unwrap(),
Value::Tuple(
TupleData::from_data(vec![("account".into(), Value::Principal(principal))])
.unwrap(),
),
TipRequest::UseLatestAnchoredTip,
false,
)
},
|ref http_request,
ref http_response,
ref mut peer_client,
ref mut peer_server,
ref convo_client,
ref convo_server| {
let req_md = http_request.preamble().clone();
match http_response {
HttpResponseType::GetMapEntry(response_md, data) => {
assert_eq!(
Value::try_deserialize_hex_untyped(&data.data).unwrap(),
Value::some(Value::Tuple(
TupleData::from_data(vec![("units".into(), Value::Int(123))])
.unwrap()
))
.unwrap()
);
true
}
_ => {
error!("Invalid response; {:?}", &http_response);
false
}
}
},
);
}

#[test]
#[ignore]
fn test_rpc_get_map_entry_unconfirmed() {
// Test v2/map_entry (aka GetMapEntry) endpoint.
// In this test, we set `tip_req` to UseLatestUnconfirmedTip, and we expect that querying for map data
// against the unconfirmed state will succeed.
test_rpc(
function_name!(),
40140,
40141,
50140,
50141,
true,
|ref mut peer_client,
ref mut convo_client,
ref mut peer_server,
ref mut convo_server| {
let unconfirmed_tip = peer_client
.chainstate()
.unconfirmed_state
.as_ref()
.unwrap()
.unconfirmed_chain_tip
.clone();
let principal =
StacksAddress::from_string("ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R")
.unwrap()
.to_account_principal();
convo_client.new_getmapentry(
StacksAddress::from_string("ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R")
.unwrap(),
"hello-world".try_into().unwrap(),
"unit-map".try_into().unwrap(),
Value::Tuple(
TupleData::from_data(vec![("account".into(), Value::Principal(principal))])
.unwrap(),
),
TipRequest::SpecificTip(unconfirmed_tip),
false,
)
},
|ref http_request,
ref http_response,
ref mut peer_client,
ref mut peer_server,
ref convo_client,
ref convo_server| {
let req_md = http_request.preamble().clone();
match http_response {
HttpResponseType::GetMapEntry(response_md, data) => {
assert_eq!(
Value::try_deserialize_hex_untyped(&data.data).unwrap(),
Value::some(Value::Tuple(
TupleData::from_data(vec![("units".into(), Value::Int(1))])
.unwrap()
))
.unwrap()
);
true
}
_ => {
error!("Invalid response; {:?}", &http_response);
false
}
}
},
// tuple key, no proof
let response = responses.remove(0);
debug!(
"Response:\n{}\n",
std::str::from_utf8(&response.try_serialize().unwrap()).unwrap()
);
}

#[test]
#[ignore]
fn test_rpc_get_map_entry_use_latest_tip() {
test_rpc(
function_name!(),
40142,
40143,
50142,
50143,
true,
|ref mut peer_client,
ref mut convo_client,
ref mut peer_server,
ref mut convo_server| {
let principal =
StacksAddress::from_string("ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R")
.unwrap()
.to_account_principal();
convo_client.new_getmapentry(
StacksAddress::from_string("ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R")
.unwrap(),
"hello-world".try_into().unwrap(),
"unit-map".try_into().unwrap(),
Value::Tuple(
TupleData::from_data(vec![("account".into(), Value::Principal(principal))])
.unwrap(),
),
TipRequest::UseLatestAnchoredTip,
false,
)
},
|ref http_request,
ref http_response,
ref mut peer_client,
ref mut peer_server,
ref convo_client,
ref convo_server| {
let req_md = http_request.preamble().clone();
match http_response {
HttpResponseType::GetMapEntry(response_md, data) => {
assert_eq!(
Value::try_deserialize_hex_untyped(&data.data).unwrap(),
Value::some(Value::Tuple(
TupleData::from_data(vec![("units".into(), Value::Int(1))])
.unwrap()
))
.unwrap()
);
true
}
_ => {
error!("Invalid response; {:?}", &http_response);
false
}
}
},
let resp = response.decode_map_entry_response().unwrap();
// `(some (tuple (units 123)))`, the value set for this principal at deploy time
assert_eq!(
resp.data,
"0x0a0c0000000105756e697473000000000000000000000000000000007b"
);
// `with_proof = false`, so no MARF proof is returned
assert_eq!(resp.marf_proof, None);
}
*/
Loading