Skip to content

Commit

Permalink
Stub out test for is_authorized
Browse files Browse the repository at this point in the history
  • Loading branch information
james-chf committed Aug 12, 2022
1 parent a5f3849 commit f93e9ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
27 changes: 23 additions & 4 deletions shared/src/ledger/eth_bridge/vp/authorize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,28 @@ use super::store;
use crate::types::address::Address;

pub(super) fn is_authorized(
reader: impl store::Reader,
tx_data: &[u8],
owner: &Address,
_reader: impl store::Reader,
_tx_data: &[u8],
_owner: &Address,
) -> Result<bool> {
Ok(false)
// TODO: integrate with how `anomac transfer` transactions will work from <https://github.com/anoma/namada/pull/297>
Ok(true)
}

#[cfg(test)]
mod tests {
use super::*;
use crate::types::address;

#[test]
fn test_is_authorized_established_address() -> Result<()> {
let reader = store::testing::FakeReader::default();
let tx_data = vec![];
let owner = address::testing::established_address_1();

let authorized = is_authorized(reader, &tx_data, &owner)?;

assert!(authorized);
Ok(())
}
}
4 changes: 2 additions & 2 deletions shared/src/ledger/eth_bridge/vp/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ where
}

#[cfg(any(test, feature = "testing"))]
mod testing {
pub(super) mod testing {
use std::collections::HashMap;

use super::*;

#[derive(Debug, Default)]
pub(super) struct FakeReader {
pub(in super::super) struct FakeReader {
pre: HashMap<Key, Vec<u8>>,
post: HashMap<Key, Vec<u8>>,
}
Expand Down

0 comments on commit f93e9ce

Please sign in to comment.