Skip to content

Commit

Permalink
make rpc test tolerant of rent_epoch being set to max
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington committed Jan 4, 2023
1 parent 10135db commit a750459
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions rpc/src/rpc_subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2700,7 +2700,9 @@ pub(crate) mod tests {
bank_forks.write().unwrap().insert(bank1);
let bank2 = Bank::new_from_parent(&bank0, &Pubkey::default(), 2);
bank_forks.write().unwrap().insert(bank2);
let alice = Keypair::new();

// we need a pubkey that will pass its rent collection slot so rent_epoch gets updated to max since this account is exempt
let alice = Keypair::from_base58_string("sfLnS4rZ5a8gXke3aGxCgM6usFAVPxLUaBSRdssGY9uS5eoiEWQ41CqDcpXbcekpKsie8Lyy3LNFdhEvjUE1wd9");

let optimistically_confirmed_bank =
OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks);
Expand Down Expand Up @@ -2784,7 +2786,7 @@ pub(crate) mod tests {
);

let response = receiver0.recv();
let expected = json!({
let mut expected = json!({
"jsonrpc": "2.0",
"method": "accountNotification",
"params": {
Expand All @@ -2802,6 +2804,15 @@ pub(crate) mod tests {
"subscription": 0,
}
});
*expected
.get_mut("params")
.unwrap()
.get_mut("result")
.unwrap()
.get_mut("value")
.unwrap()
.get_mut("rentEpoch")
.unwrap() = serde_json::to_value(u64::MAX).unwrap();
assert_eq!(
expected,
serde_json::from_str::<serde_json::Value>(&response).unwrap(),
Expand Down Expand Up @@ -2834,7 +2845,7 @@ pub(crate) mod tests {
&None,
);
let response = receiver1.recv();
let expected = json!({
let mut expected = json!({
"jsonrpc": "2.0",
"method": "accountNotification",
"params": {
Expand All @@ -2852,6 +2863,15 @@ pub(crate) mod tests {
"subscription": 1,
}
});
*expected
.get_mut("params")
.unwrap()
.get_mut("result")
.unwrap()
.get_mut("value")
.unwrap()
.get_mut("rentEpoch")
.unwrap() = serde_json::to_value(u64::MAX).unwrap();
assert_eq!(
expected,
serde_json::from_str::<serde_json::Value>(&response).unwrap(),
Expand Down

0 comments on commit a750459

Please sign in to comment.