Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Truffle Test Tips and other
Search
nakajo2011
November 10, 2018
Programming
200
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Truffle Test Tips and other
nakajo2011
November 10, 2018
More Decks by nakajo2011
See All by nakajo2011
Plasma_Overview_gbec20180928.pdf
nakajo2011
0
94
What is Ethereum about tech layer
nakajo2011
0
410
The Ethereum design direction.
nakajo2011
0
92
Report of Devcon5 2019.10.17
nakajo2011
0
650
Compare of Libra and Ethereum
nakajo2011
1
470
What is Move language
nakajo2011
1
1.2k
blockchain-changing-and-issues
nakajo2011
4
590
Thinking Scalability from DEX
nakajo2011
0
120
Truffleの紹介_in_hicon2018.pdf
nakajo2011
3
330
Other Decks in Programming
See All in Programming
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
230
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
Modding RubyKaigi for Myself
yui_knk
0
910
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
860
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
1.9k
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
4.9k
A2UI という光を覗いてみる
satohjohn
1
120
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
130
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
640
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.3k
Claspは野良GASの夢をみるか
takter00
0
180
Featured
See All Featured
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
230
Building AI with AI
inesmontani
PRO
1
1.1k
Bash Introduction
62gerente
615
210k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
160
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
150
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
850
How STYLIGHT went responsive
nonsquared
100
6.2k
Embracing the Ebb and Flow
colly
88
5.1k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
540
Google's AI Overviews - The New Search
badams
0
1k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.4k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Transcript
Copyright ©2018 chaintope, Inc. all rights reserved. hicon2018 Truffle Test
Tips 2018/11/10 chaintope, Inc Yukishige Nakajo
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. Step - 2
1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. Step - 3
1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. # Analysis result
for BatchOverFlowToken: ~~ snip ~~ ==== Integer Overflow ==== SWC ID: 101 Type: Warning Contract: BatchOverFlowToken Function name: batchTransfer(address[],uint256) PC address: 2599 -------------------- In file: BatchOverFlowToken.sol:20 uint256(cnt) * _value -------------------- 1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. Step - 4
1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. ・truffle embeded node
or ganache-cliの場合 2. Truffle Testの起動シーケンス
Copyright ©2018 chaintope, Inc. all rights reserved. ・ganache-cli以外のnode(like go-ethereum) 2.
Truffle Testの起動シーケンス
Copyright ©2018 chaintope, Inc. all rights reserved. Truffleではクリーンな環境を作成する https://truffleframework.com/docs/truffle/testing/testing-your-contracts#clean-room-environment 1.
ganache-cli使う時と、go-ethereumなどを使う時で動作 が異なるので注意 2. コンパイルが通らないとNG a. solidity編集中にちょっとテストを。。ができない 3. Migrationが通らないとNG a. migration fileを作っている場合は特に注意 2. Truffle Testの起動シーケンス
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Contract.new() • 新しくsmart
contractのインスタンスを生成する • つまりnetworkにdeployされる • 基本的にはこれを使って書く • new()するたびにcontract addressは変わるので注意 • deployに膨大なgasを使うContractの場合、gasが不足 するかもしれないので注意 • その場合はgasPrice=1とかにしちゃえばいい 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Contract.deployed() • 事前にmigrationでdeployされたSmart
Contractのイン スタンスが帰ってくる • truffle devの時は基本的に使えない • ganache-cliの時は自分でmigrationを事前にする必 要がある 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Contract.deployed() • あまり使ったことはない
• インスタンス取得にdeployする必要がないので高速 • でも前の状態を保持しているので注意が必要 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. 4. HowTo
Event Test
Copyright ©2018 chaintope, Inc. all rights reserved. • Contract.EventName()なメソッドでEventは定義されて いる
• 引数は順番に次の3つ • topics : indexedをつけたparameterを絞り込む • term: Eventをキャッチするblock範囲 • callback: Filterに関係するeventが発生した時に呼ば れる 4. HowTo Event Test
Copyright ©2018 chaintope, Inc. all rights reserved. • Eventが発生したかどうかは結構重要 •
Eventが余分に発生していないこともチェックする必要が あある 4. HowTo Event Test
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. 5. Dapp Projects
test statistic
Copyright ©2018 chaintope, Inc. all rights reserved. • Research 20
Dapps • Make test projects: 4 • Not have test projects: 9 • Not found repository: 7 Has Test Project is 30 % 5. Dapp Projects test statistic
Copyright ©2018 chaintope, Inc. all rights reserved. ちなみに・・・・ TheDAO has
test …... https://github.com/slockit/DAO/tree/develop/tests 5. Dapp Projects test statistic
Copyright ©2018 chaintope, Inc. all rights reserved. 長時間ありがとうございました! おわり