Skip to content

Commit 92c104c

Browse files
committed
tests: Add UI tests for ABI specific constructor rules
1 parent 854ea4f commit 92c104c

File tree

6 files changed

+109
-0
lines changed

6 files changed

+109
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![allow(unexpected_cfgs)]
2+
3+
#[ink::contract]
4+
mod contract {
5+
#[ink(storage)]
6+
pub struct Contract {}
7+
8+
impl Contract {
9+
#[ink(constructor)]
10+
pub fn constructor_1() -> Self {
11+
Self {}
12+
}
13+
14+
#[ink(constructor)]
15+
pub fn constructor_2() -> Self {
16+
Self {}
17+
}
18+
19+
#[ink(message)]
20+
pub fn message(&self) {}
21+
}
22+
}
23+
24+
fn main() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error: One constructor used for Solidity ABI encoded instantiation must be annotated with the `default` attribute argument in "all" ABI mode
2+
--> tests/ui/abi/all/fail/constructors-no-default.rs:4:1
3+
|
4+
4 | / mod contract {
5+
5 | | #[ink(storage)]
6+
6 | | pub struct Contract {}
7+
... |
8+
22 | | }
9+
| |_^
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![allow(unexpected_cfgs)]
2+
3+
#[ink::contract]
4+
mod contract {
5+
#[ink(storage)]
6+
pub struct Contract {}
7+
8+
impl Contract {
9+
#[ink(constructor, default)]
10+
pub fn constructor_1() -> Self {
11+
Self {}
12+
}
13+
14+
#[ink(constructor)]
15+
pub fn constructor_2() -> Self {
16+
Self {}
17+
}
18+
19+
#[ink(message)]
20+
pub fn message(&self) {}
21+
}
22+
}
23+
24+
fn main() {}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![allow(unexpected_cfgs)]
2+
3+
#[ink::contract]
4+
mod contract {
5+
#[ink(storage)]
6+
pub struct Contract {}
7+
8+
impl Contract {
9+
#[ink(constructor)]
10+
pub fn constructor_1() -> Self {
11+
Self {}
12+
}
13+
14+
#[ink(constructor)]
15+
pub fn constructor_2() -> Self {
16+
Self {}
17+
}
18+
19+
#[ink(message)]
20+
pub fn message(&self) {}
21+
}
22+
}
23+
24+
fn main() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error: multiple constructors are not supported in Solidity ABI compatibility mode
2+
--> tests/ui/abi/sol/fail/constructors.rs:4:1
3+
|
4+
4 | / mod contract {
5+
5 | | #[ink(storage)]
6+
6 | | pub struct Contract {}
7+
... |
8+
22 | | }
9+
| |_^
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![allow(unexpected_cfgs)]
2+
3+
#[ink::contract]
4+
mod contract {
5+
#[ink(storage)]
6+
pub struct Contract {}
7+
8+
impl Contract {
9+
#[ink(constructor)]
10+
pub fn constructor() -> Self {
11+
Self {}
12+
}
13+
14+
#[ink(message)]
15+
pub fn message(&self) {}
16+
}
17+
}
18+
19+
fn main() {}

0 commit comments

Comments
 (0)