I am implementing a project using the directory structure proposed by openbrush. The contract compiles without a problem, but when it comes to testing I run into the following error:
error[E0599]: no function or associated item named `new` found for trait object `dyn project_name::traits::traitName::TraitName` in the current scope --> tests/integrations_tests.rs:148:30 | 148 | let contract = TraitName::new(input); | ^^^ function or associated item not found in `dyn project_name::traits::traitName::TraitName`
Do I need to declare the constructor in the trait somewhere?
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(min_specialization)]
#[openbrush::contract]
pub mod name {
use project_name::traits::traitName::*;
impl TraitName {
#[ink(constructor)]
pub fn new(input: bool) -> Self {
ink_lang::codegen::initialize_contract(|contract: & mut Self| {
Self::new_init(contract, input)
})
}
fn new_init(&mut self, input: bool) {
// do smth with input
}
}
#[cfg(test)]
mod tests {
use super::*;
use ink_lang as ink;
#[ink::test]
fn test_nr_1(){
let contract = TraitName::new(true);
// stuff to test with contract
}
}
}