Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Fix the failed unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Jun 1, 2021
1 parent 15fb6f7 commit 4e1d0b3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
25 changes: 19 additions & 6 deletions frame/dvm/src/mock.rs
Expand Up @@ -22,17 +22,20 @@ use crate::{
*,
};
use codec::{Decode, Encode};
use darwinia_evm::{AddressMapping, EnsureAddressTruncated, FeeCalculator, IssuingHandler};
use darwinia_evm::{AddressMapping, EnsureAddressTruncated, FeeCalculator};
use dp_evm::Precompile;
use ethereum::{TransactionAction, TransactionSignature};
use frame_support::{traits::GenesisBuild, ConsensusEngineId, PalletId};
use evm::{Context, ExitError, ExitSucceed};
use frame_support::{traits::GenesisBuild, ConsensusEngineId};
use frame_system::mocking::*;
use rlp::*;
use sp_core::{H160, H256, U256};
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
AccountId32, DispatchResult, Perbill, RuntimeDebug,
AccountId32, Perbill, RuntimeDebug,
};
use sp_std::{marker::PhantomData, vec::Vec};

darwinia_support::impl_test_account_data! {}

Expand Down Expand Up @@ -136,7 +139,6 @@ impl FindAuthor<H160> for EthereumFindAuthor {
frame_support::parameter_types! {
pub const TransactionByteFee: u64 = 1;
pub const ChainId: u64 = 42;
pub const EVMPalletId: PalletId = PalletId(*b"py/evmpa");
pub const BlockGasLimit: U256 = U256::MAX;
}

Expand All @@ -150,6 +152,17 @@ impl AddressMapping<AccountId32> for HashedAddressMapping {
}
}

pub struct RingBack<T>(PhantomData<T>);
impl<T: darwinia_evm::Config> Precompile for RingBack<T> {
fn execute(
input: &[u8],
target_gas: Option<u64>,
context: &Context,
) -> core::result::Result<(ExitSucceed, Vec<u8>, u64), ExitError> {
darwinia_evm_precompile_transfer::ring::RingBack::<T>::transfer(&input, target_gas, context)
}
}

impl darwinia_evm::Config for Test {
type FeeCalculator = FixedGasPrice;
type GasWeightMapping = ();
Expand All @@ -163,7 +176,7 @@ impl darwinia_evm::Config for Test {
darwinia_evm_precompile_simple::Sha256,
darwinia_evm_precompile_simple::Ripemd160,
darwinia_evm_precompile_simple::Identity,
darwinia_evm_precompile_withdraw::WithDraw<Self>,
RingBack<Test>,
);
type ChainId = ChainId;
type BlockGasLimit = BlockGasLimit;
Expand All @@ -173,7 +186,7 @@ impl darwinia_evm::Config for Test {
type IssuingHandler = ();
}

impl Config for Test {
impl dvm_ethereum::Config for Test {
type Event = ();
type FindAuthor = EthereumFindAuthor;
type StateRoot = IntermediateStateRoot;
Expand Down
5 changes: 2 additions & 3 deletions frame/evm/precompile/contracts/transfer/src/lib.rs
Expand Up @@ -18,8 +18,8 @@

#![cfg_attr(not(feature = "std"), no_std)]

mod kton;
mod ring;
pub mod kton;
pub mod ring;
pub mod util;

// --- substrate ---
Expand All @@ -37,7 +37,6 @@ pub type AccountId<T> = <T as frame_system::Config>::AccountId;
/// Transfer Precompile Contract, used to support the exchange of KTON and RING tranfer.
///
/// The contract address: 0000000000000000000000000000000000000015
#[derive(PartialEq, Eq, Debug)]
pub enum Transfer<T> {
/// Transfer RING bach from dvm to darwinia
RingBack,
Expand Down
2 changes: 1 addition & 1 deletion frame/evm/precompile/contracts/transfer/src/ring.rs
Expand Up @@ -21,7 +21,7 @@ impl<T: Config> RingBack<T> {
/// 2. transfer from the contract address to withdrawal address
///
/// Input data: 32-bit substrate withdrawal public key
pub(crate) fn transfer(
pub fn transfer(
input: &[u8],
_: Option<u64>,
context: &Context,
Expand Down

0 comments on commit 4e1d0b3

Please sign in to comment.