mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Implement feerecipient API for keymanager (#3213)
## Issue Addressed * #3173 ## Proposed Changes Moved all `fee_recipient_file` related logic inside the `ValidatorStore` as it makes more sense to have this all together there. I tested this with the validators I have on `mainnet-shadow-fork-5` and everything appeared to work well. Only technicality is that I can't get the method to return `401` when the authorization header is not specified (it returns `400` instead). Fixing this is probably quite difficult given that none of `warp`'s rejections have code `401`.. I don't really think this matters too much though as long as it fails.
This commit is contained in:
@@ -249,66 +249,6 @@ fn fee_recipient_flag() {
|
||||
)
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn fee_recipient_file_flag() {
|
||||
let dir = TempDir::new().expect("Unable to create temporary directory");
|
||||
let mut file =
|
||||
File::create(dir.path().join("fee_recipient.txt")).expect("Unable to create file");
|
||||
let new_key = Keypair::random();
|
||||
let pubkeybytes = PublicKeyBytes::from(new_key.pk);
|
||||
let contents = "default:0x00000000219ab540356cbb839cbe05303d7705fa";
|
||||
file.write_all(contents.as_bytes())
|
||||
.expect("Unable to write to file");
|
||||
CommandLineTest::new()
|
||||
.flag(
|
||||
"suggested-fee-recipient-file",
|
||||
dir.path().join("fee_recipient.txt").as_os_str().to_str(),
|
||||
)
|
||||
.run()
|
||||
.with_config(|config| {
|
||||
// Public key not present so load default.
|
||||
assert_eq!(
|
||||
config
|
||||
.fee_recipient_file
|
||||
.clone()
|
||||
.unwrap()
|
||||
.load_fee_recipient(&pubkeybytes)
|
||||
.unwrap(),
|
||||
Some(Address::from_str("0x00000000219ab540356cbb839cbe05303d7705fa").unwrap())
|
||||
)
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn fee_recipient_file_with_pk_flag() {
|
||||
let dir = TempDir::new().expect("Unable to create temporary directory");
|
||||
let mut file =
|
||||
File::create(dir.path().join("fee_recipient.txt")).expect("Unable to create file");
|
||||
let new_key = Keypair::random();
|
||||
let pubkeybytes = PublicKeyBytes::from(new_key.pk);
|
||||
let contents = format!(
|
||||
"{}:0x00000000219ab540356cbb839cbe05303d7705fa",
|
||||
pubkeybytes.to_string()
|
||||
);
|
||||
file.write_all(contents.as_bytes())
|
||||
.expect("Unable to write to file");
|
||||
CommandLineTest::new()
|
||||
.flag(
|
||||
"suggested-fee-recipient-file",
|
||||
dir.path().join("fee_recipient.txt").as_os_str().to_str(),
|
||||
)
|
||||
.run()
|
||||
.with_config(|config| {
|
||||
assert_eq!(
|
||||
config
|
||||
.fee_recipient_file
|
||||
.clone()
|
||||
.unwrap()
|
||||
.load_fee_recipient(&pubkeybytes)
|
||||
.unwrap(),
|
||||
Some(Address::from_str("0x00000000219ab540356cbb839cbe05303d7705fa").unwrap())
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
// Tests for HTTP flags.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user