-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.rb
52 lines (40 loc) · 1.42 KB
/
test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# encoding: utf-8
require 'universum'
TicTacToe = Contract.load( './tictactoe' )
pp TicTacToe
####
# setup test accounts
Account[ '0xaaaa' ]
Account[ '0xbbbb' ]
tx = Uni.send_transaction( from: '0xaaaa', data: [TicTacToe] )
tictactoe = tx.receipt.contract
pp tictactoe
Uni.send_transaction( from: '0xaaaa', to: tictactoe, data: [:create, '0xbbbb', '0xaaaa'])
pp tictactoe
# 1st move by 0xaaaaa
Uni.send_transaction( from: '0xaaaa', to: tictactoe, data: [:move, '0xbbbb', '0xaaaa', '0xaaaa', 0, 0])
pp tictactoe
# 1st move by 0xbbbb
Uni.send_transaction( from: '0xbbbb', to: tictactoe, data: [:move, '0xbbbb', '0xaaaa', '0xbbbb', 0, 1])
pp tictactoe
# 2nd move by 0xaaaa
Uni.send_transaction( from: '0xaaaa', to: tictactoe, data: [:move, '0xbbbb', '0xaaaa', '0xaaaa', 1, 1])
pp tictactoe
# 2nd move by 0xbbbb
Uni.send_transaction( from: '0xbbbb', to: tictactoe, data: [:move, '0xbbbb', '0xaaaa', '0xbbbb', 0, 2])
pp tictactoe
# 3rd move by 0xaaaa - WIN!
Uni.send_transaction( from: '0xaaaa', to: tictactoe, data: [:move, '0xbbbb', '0xaaaa', '0xaaaa', 2, 2])
pp tictactoe
###
# try restart
Uni.send_transaction( from: '0xaaaa', to: tictactoe, data: [:restart, '0xbbbb', '0xaaaa', '0xaaaa'])
pp tictactoe
###
# try cleanup
Uni.send_transaction( from: '0xaaaa', to: tictactoe, data: [:close, '0xbbbb', '0xaaaa'])
pp tictactoe
##
# try another game
Uni.send_transaction( from: '0xbbbb', to: tictactoe, data: [:create, '0xaaaa', '0xbbbb'])
pp tictactoe