forked from rooch-network/rooch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '9811b7dbf465070d33d0b3ce7ed9c879fb937048'
* commit '9811b7dbf465070d33d0b3ce7ed9c879fb937048': [rooch-networkgh-472] add helper function if modules are empty. (rooch-network#473) [AccountAbstraction] Implement AuthenticatorAbstraction (rooch-network#466)
- Loading branch information
Showing
47 changed files
with
2,383 additions
and
900 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
crates/rooch-framework/doc linguist-generated=true | ||
moveos/moveos-stdlib/move-stdlib/doc linguist-generated=true | ||
moveos/moveos-stdlib/moveos-stdlib/doc linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use anyhow::Result; | ||
use moveos::moveos::MoveOS; | ||
use moveos_store::MoveOSDB; | ||
use moveos_types::module_binding::{ModuleBundle, MoveFunctionCaller}; | ||
use rooch_genesis::RoochGenesis; | ||
|
||
pub struct RustBindingTest { | ||
moveos: MoveOS, | ||
} | ||
|
||
impl RustBindingTest { | ||
pub fn new() -> Result<Self> { | ||
let moveosdb = MoveOSDB::new_with_memory_store(); | ||
let genesis: &RoochGenesis = &rooch_genesis::ROOCH_GENESIS; | ||
|
||
let mut moveos = MoveOS::new(moveosdb, genesis.all_natives(), genesis.config.clone())?; | ||
if moveos.state().is_genesis() { | ||
moveos.init_genesis(genesis.genesis_txs())?; | ||
} | ||
Ok(Self { moveos }) | ||
} | ||
|
||
pub fn as_module_bundle<'a, M: ModuleBundle<'a>>(&'a self) -> M { | ||
self.moveos.as_module_bundle::<M>() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pub mod binding_test; | ||
#[cfg(test)] | ||
mod tests; |
30 changes: 30 additions & 0 deletions
30
crates/rooch-framework-tests/src/tests/ed25519_validator_tests.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use moveos_types::transaction::MoveAction; | ||
use rooch_framework::bindings::empty::Empty; | ||
use rooch_key::keystore::{AccountKeystore, InMemKeystore}; | ||
use rooch_types::transaction::{rooch::RoochTransactionData, AbstractTransaction}; | ||
|
||
use crate::binding_test; | ||
|
||
#[test] | ||
fn test_validate() { | ||
let binding_test = binding_test::RustBindingTest::new().unwrap(); | ||
let ed25519_validator = binding_test | ||
.as_module_bundle::<rooch_framework::bindings::ed25519_validator::Ed25519Validator>( | ||
); | ||
|
||
let keystore = InMemKeystore::new_insecure_for_tests(1); | ||
let sender = keystore.addresses()[0]; | ||
let sequence_number = 0; | ||
let action = MoveAction::new_function_call(Empty::empty_function_id(), vec![], vec![]); | ||
let tx_data = RoochTransactionData::new(sender, sequence_number, action); | ||
let tx = keystore.sign_transaction(&sender, tx_data).unwrap(); | ||
let auth_info = tx.authenticator_info(); | ||
let move_tx = tx.construct_moveos_transaction(sender.into()).unwrap(); | ||
|
||
ed25519_validator | ||
.validate(&move_tx.ctx, auth_info.authenticator.payload) | ||
.unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::binding_test; | ||
use moveos_types::tx_context::TxContext; | ||
|
||
#[test] | ||
fn test_empty() { | ||
let binding_test = binding_test::RustBindingTest::new().unwrap(); | ||
let empty = binding_test.as_module_bundle::<rooch_framework::bindings::empty::Empty>(); | ||
let ctx = TxContext::random_for_testing_only(); | ||
empty.empty(&ctx).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
mod ed25519_validator_tests; | ||
mod empty_tests; | ||
mod transaction_validator_tests; |
28 changes: 28 additions & 0 deletions
28
crates/rooch-framework-tests/src/tests/transaction_validator_tests.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use moveos_types::transaction::MoveAction; | ||
use rooch_framework::bindings::empty::Empty; | ||
use rooch_key::keystore::{AccountKeystore, InMemKeystore}; | ||
use rooch_types::transaction::{rooch::RoochTransactionData, AbstractTransaction}; | ||
|
||
use crate::binding_test; | ||
|
||
#[test] | ||
fn test_validate() { | ||
let binding_test = binding_test::RustBindingTest::new().unwrap(); | ||
let transaction_validator = binding_test.as_module_bundle::<rooch_framework::bindings::transaction_validator::TransactionValidator>(); | ||
|
||
let keystore = InMemKeystore::new_insecure_for_tests(1); | ||
let sender = keystore.addresses()[0]; | ||
let sequence_number = 0; | ||
let action = MoveAction::new_function_call(Empty::empty_function_id(), vec![], vec![]); | ||
let tx_data = RoochTransactionData::new(sender, sequence_number, action); | ||
let tx = keystore.sign_transaction(&sender, tx_data).unwrap(); | ||
let auth_info = tx.authenticator_info(); | ||
let move_tx = tx.construct_moveos_transaction(sender.into()).unwrap(); | ||
|
||
transaction_validator | ||
.validate(&move_tx.ctx, auth_info) | ||
.unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.